PDA

View Full Version : OpenGL 3.0 Texture Problems.



LangFox
03-24-2009, 03: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, 03:58 AM
I don't have a problem creating BGRA textures the exact same way in GL3.0 forward-compatible. GF8600 latest drivers.

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

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

LangFox
03-24-2009, 09: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

LangFox
03-25-2009, 10: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[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
0, 0,//WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
0, 0
};

Jackis
03-26-2009, 03: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.

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

glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);

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.

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