PDA

View Full Version : GL_RGBA crashes the program ???



yaro_dup1
02-09-2003, 10:29 AM
Hi,

I saw that if I pass the GL_RGBA to glTexImage2D the program crashes.
Why? I did check this in my programs and in NeHe's tutorials too. And it's not only my problem. What's going on with GL_RGBA?

thanks

Bob
02-09-2003, 10:50 AM
You're doing something wrong. If you want a more detailed answer, you need to ask a more detailed question.

Stack Overflow
02-09-2003, 05:24 PM
Hello glYaro,

I would like to know if you are using GLUT or Win32?

Now, if you are using Win32, you might want to use the PIXELFORMATDESCRIPTOR function, and here is an example, and as you will see, it will define the GL_RGBA function in the iPixelType definition:




void InitGL( HWND hWnd, HDC & hDC, HGLRC & hRC ) {
PIXELFORMATDESCRIPTOR pfd;
ZeroMemory( &pfd, sizeof pfd );
pfd.nSize = sizeof pfd;
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_GENERIC_ACCELERATED | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_SWAP_LAYER_BUFFERS;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;

hDC = GetDC( hWnd );

int i = ChoosePixelFormat( hDC, &pfd );
SetPixelFormat( hDC, i, &pfd );

hRC = wglCreateContext( hDC );
wglMakeCurrent( hDC, hRC );
}


and If you are using GLUT, please make sure you are intialzing your DisplayMode code like this:




glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA );


You may change these functions if you don't want double buffering and/or etc...

I hope this helps, and if not, please inform me of a more explanatory description of your problem.

- VC6-OGL

Mazy
02-10-2003, 01:09 AM
It could be that your loaded imagedata only is RGB, so when yuo tries to upload it to opengl as RGBA you read from memory that arent allocated and then you will get a read-error

yaro_dup1
02-13-2003, 09:14 AM
Hi,

Sorry for late (I was on programming contest four days).

I dont use GLUT. The problem is that I'm reading TGA file which is RGBA type.
I think maybe it won't be necessary to use GL_RGBA in glTexImage2D because I can make textured mapped fonts without it.

-yaro

Stack Overflow
02-13-2003, 10:00 AM
Hello glYaro,

I will be in my Chat room in about 3 hours, just in case you would like to join.

- VC6-OGL