I am using OpenGL fix function pipeline. I have been looking for a way to deactivate the texture units correctly. I am not convince with the way I am doing it right now. I do something like this to disable Texture Unit 1 for instance.
I see no reason why the texture unit should be disabled if it does not uses a texture. It seems to me there is something missing to make sure that a texture unit is really disabled and that no subsequent texture unit will be used for the fragment.
How do you disable a texture unit so the result produced by the preceding unit becomes the final result?
No contest! I know this works and I use it all the time. However, I was hoping an explanation or maybe a reference in the opengl spec or extension where it is made clear how to disable a texture unit. Unfortunately, I haven’t found it myself.
If my texture unit environment does not use a texture, why is it that glDisable(GL_TEXTURE_1D/2D/3D/Cube/Rectangle) is enough to disable a texture unit that is correctly set?
It’s right there in the spec (2.1, section 3.8.16 Texture Application):
“Texturing is enabled and disabled individually for each texture unit. If texturing
is disabled for one of the units, then the fragment resulting from the previous unit
is passed unaltered to the following unit.”
In other words, if there is not a valid (mipmap complete) texture bound and enabled on a unit, the unit is no-oped, regardless of the TexEnv/TexCombine state. That also means that if you only want to use non-texture inputs on a unit (like PRIMARY_COLOR, or CONSTANT) you still need to have a valid (dummy) texture bound.
Thank you for the precision. I was intrigued by the fact there wasn’t a single function to disable a texture unit. I thought I was missing something. A single line command instead of many calls would have been nice though!
Of course you still need to ‘select’ your textures with glBindTexture(GL_TEXTURE_2D, texname); in both situations.
Though glDisable(GL_TEXTURE_2D) has now become obsolete if you use shaders.