View Full Version : OpenGL 3.0 Texture Problems.

03-24-2009, 02:39 AM
Hey guys,

I tried OpenGL 3.0 today. It's OK to create a forward-compatible 3.0 context. But problems occurred in some cases(ALL these never happen with OpenGL 2.1):

1, When texture format is GL_BGRA.

GLuint unTextureID = 0;
glGenTextures(1, &unTextureID);
glBindTexture(GL_TEXTURE_2D, unTextureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);

GLExpert reports:

OGLE: Category: 0x00000001, MessageID: 0x00800001
A provided enum value is not accepted by this operation: OGL Error Code = 0x00000500 (GL_INVALID_ENUM)

2, When I set a sampler value.

int n_txDiffuse = glGetUniformLocation(hProgram, "g_txDiffuse");
glUniform1i(n_txDiffuse, 0);

GLExpert reports:

OGLE: Category: 0x00000001, MessageID: 0x00800003
The current operation is illegal in the current state: OGL Error Code = 0x00000502 (GL_INVALID_OPERATION)

So, any suggestion?

Ilian Dinev
03-24-2009, 02:58 AM
I don't have a problem creating BGRA textures the exact same way in GL3.0 forward-compatible. GF8600 latest drivers.

03-24-2009, 04:46 PM
I'm using "182.46_geforce_winvista_32bit_english_beta" with GF8800GTS...strange~

Ilian Dinev
03-24-2009, 04:56 PM
Oh, my bad, I don't use the newest drivers. My GL_VERSION returns "3.0 NVIDIA 181.22". XP sp2.

03-24-2009, 08:52 PM
More problem with NVIDIAGPUVista(182_47) on 8800GTS:

After I create a 3.1 context, the GLSL version reported is still 1.30.

OpenGL Vendor : NVIDIA Corporation
OpenGL Renderer : GeForce 8800 GTS 512/PCI/SSE2
OpenGL Version : 3.1 NVIDIA 182.47
OpenGL Shader Version : 1.30 NVIDIA via Cg compiler

03-25-2009, 09:53 PM
Occasionally, I find the texture problem was caused by the attribList setting:

If I don't set "WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB", everything is ok, no GLError will be reported.

int attribList[] =
0, 0

03-26-2009, 02:10 AM
So it's something to deal with deprecated features. May be, some of formats are deprecated, I can't say more precise, sorry, cause I didn't look deeply in new specification.

03-28-2009, 07:28 PM
I get the same error. Maybe try using GL_RGBA


This is on page 103 of the new 3.1 spec. It was referred by the format parameter description of glTexImage2D

edit: I didn't really test this yet, try it out.

03-29-2009, 10:04 AM
It seems that GL_BGRA will not work with glTexImage, but will with glTexSubImage.