Why glDisable(TEXTURE_2D) does not work?

Started by
14 comments, last by riruilo 14 years, 1 month ago
Hi mates! My renderable objects can use a texture or just a color. Texturing is not activated by default. If my object uses a texture, it activates it, render some object and deactivates it using: glBindTexture(GL_TEXTURE_2D,0); But I don't know why next object is rendered using last texture, even if I disable texturing explicitly before rendering it. However if also use glBindTexture(GL_TEXTURE_2D,0) just before glDisable(TEXTURE_2D), everything works fine. My question is: Should I always use glBindTexture(GL_TEXTURE_2D,0) and glDisable(TEXTURE_2D) at the same time? I thought glDisable(TEXTURE_2D) was enough. What do you think? Thanks a lot.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Advertisement
Binding the default texture is not a substitute to disabling texturing. If you bind the default texture object, you still have texturing enabled and a texture object bound, and you can expect unexpected behavior at some point which will be difficult to locate. The only issue apparent from your post is the wrong symbol passed to glDisable; have you defined TEXTURE_2D somewhere, or is that just a misprint?

All that, however, assumes you're using the deprecated fixed function set. When using shaders, the concept of texture units being enabled and disabled doesn't exist anymore.
Oh and remember to disable texturing for texture layers you don't use if using the fixed pipeline :)

But it's correct. Binding to zero will only lead to problems later on.
try glDisable(GL_TEXTURE_2D); instead.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Quote:Original post by SimonForsman
try glDisable(GL_TEXTURE_2D); instead.


It was a typo. My code does not have that typo.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
If you are using shaders, the call to glEnable/glDisable(GL_TEXTURE_2D) has no effect.
Link: OpenGL Wiki: Enable Or Not To Enable
Quote:Original post by Ignifex
If you are using shaders, the call to glEnable/glDisable(GL_TEXTURE_2D) has no effect.
Link: OpenGL Wiki: Enable Or Not To Enable


Nope. This time I'm using fixed pipeline.

Interesting link.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
In that case, you might be using multitexturing, where you'll need to disable every bound GL_TEXTUREi seperately.
Otherwise, a call to disable texturing will tell the fixed pipeline not to use a texture when shading the fragments. I can think of a few more things to check:
- Are you not blending your previous drawing with the new one somehow? If it's drawn on a seperate position, then this is likely not the case.
- Are you certain you are calling glDisable(GL_TEXTURE_2D) before your second drawing calls? And you are not re-enabling it somewhere?
- What happens if you do not draw the first object, ie. leave out only the actual drawing calls, leaving the state changes as they are?
If you are certain all of this does not work, then you'll have to post more code/driver info etc.
Quote:Original post by Ignifex
In that case, you might be using multitexturing, where you'll need to disable every bound GL_TEXTUREi seperately.
Otherwise, a call to disable texturing will tell the fixed pipeline not to use a texture when shading the fragments. I can think of a few more things to check:
- Are you not blending your previous drawing with the new one somehow? If it's drawn on a seperate position, then this is likely not the case.
- Are you certain you are calling glDisable(GL_TEXTURE_2D) before your second drawing calls? And you are not re-enabling it somewhere?
- What happens if you do not draw the first object, ie. leave out only the actual drawing calls, leaving the state changes as they are?
If you are certain all of this does not work, then you'll have to post more code/driver info etc.


Thanks for reply.

I'm not using blending modes or multitexturing, just one texture. I don't understand why I have this problem.

Thanks for help.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Are you calling a display list that has a texture binding or enabling call inside it? Are you disabling the right texture unit?

This topic is closed to new replies.

Advertisement