Sign in to follow this  

Why glDisable(TEXTURE_2D) does not work?

This topic is 2843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Daaark
Are you calling a display list that has a texture binding or enabling call inside it? Are you disabling the right texture unit?


Nope, I'm using inmediate mode and gluCylinder with gluQuadricNormals, gluQuadricTexture

Share this post


Link to post
Share on other sites
Quote:
Original post by SimonForsman
try glDisable(GL_TEXTURE_2D); instead.


SimonForsman, you were almost right. Sometimes I used GL_TEXTURE instead of GL_TEXTURE_2D in my source code.

Now my code works perfectly.

Thanks a lot SimonForsman and all.

Share this post


Link to post
Share on other sites
Quote:
Original post by Brother Bob
Which shows why there is a huge difference between copy-pasting code and writing it from your memory. Get into the habit of always copy-pasting code you have problems with, no matter how trivial it is.


You are absolutly right ;)

Share this post


Link to post
Share on other sites

This topic is 2843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this