Jump to content
  • Advertisement
Sign in to follow this  
riruilo

Why glDisable(TEXTURE_2D) does not work?

This topic is 3183 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
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.

Share this post


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

Share this post


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


It was a typo. My code does not have that typo.

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
Are you calling a display list that has a texture binding or enabling call inside it? Are you disabling the right texture unit?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!