Disable Texture Coordinate Generation

Hi Everyone!

I’m having problems resetting the texture state on one of my texture units in
an OpenGL application I’m writing with OpenGL 2.1 on Linux.

I’m rendering my geometry into a shadow map bound to texture unit 0 (out of 4
available texture units on my machine). Later I use the texture (still bound
to texture unit 0) to render shadows to my scene.

At the end of each frame I want to draw some HUD elements to the screen using
the same texture unit. But the HUD quad with the texture applied is drawn like
a single color quad whos color seems to depend on which way the camera is

I suspected that the problem was that I had texture coordinate generation
active for the current texture unit. But, even if I disable texture coordinate
generation in the HUD drawing function, the result is still exactly the same
as before.

glActiveTexture( GL_TEXTURE0);
glBindTexture( GL_TEXTURE0, iHudTexture);
glDisable( GL_TEXTURE_GEN_S);
glDisable( GL_TEXTURE_GEN_T);
glDisable( GL_TEXTURE_GEN_R);
glDisable( GL_TEXTURE_GEN_Q);

I’m starting to run out of ideas about this thing, I hope someone can point me
in the right direction.

Thanks in advance


it could be the texture matrix, you can reset it using

glLoadIdentity ();

Hi, thanks for the reply!

I tried to reset the texture matrix too, but the problem persists unfortunately.

But the HUD quad with the texture applied is drawn like
a single color quad whos color seems to depend on which way the camera is

Sounds like lighting still enabled…



before drawing any huds, and in case you are using it, also reset the texture compare mode:


I tried to do


It does not seem to work either.

You’ve got the source, so you’re definitely the best to determine which GL state your setting in your app and thus the candidate states that might need reset.

At the top of your renderer before you start messing with these textures, try:

glPushAttrib( GL_ALL_ATTRIB_BITS );

and between the shadow render and scene render at the appropriate point, put a:

glPushAttrib( GL_ALL_ATTRIB_BITS );

see if you can make the problem go away. If you can, then try refining the push/pop to only certain groups of attributes.

Another possibility is to use a tool like gDEBugger, and snapshot the state at app startup, and compare to app state at the point you’re about to rendering something with the problem. Diff for ideas.

Also, you are doing a glOrtho to wax your perspective and get a parallel PROJECTION matrix, aren’t you? You’ll also want a fresh VIEWING matrix that unlike the scene is prob static and doesn’t change.

Or start commenting the shadow drawing code out, until the hud works, then you’ll know wich state is causing trouble.

Nice suggestions, I’ll start investigating, when I get home later tonight.