GL_RGBA crashes the program ???


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?


You’re doing something wrong. If you want a more detailed answer, you need to ask a more detailed question.

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 ) {
ZeroMemory( &pfd, sizeof pfd );
pfd.nSize = sizeof pfd;
pfd.nVersion = 1;
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

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


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.


Hello glYaro,

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

  • VC6-OGL