Jump to content
  • Advertisement
Sign in to follow this  
THACO

UnBind a texture

This topic is 4861 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

I bind a texture that I loaded up and draw some triangles, then I want to draw more triagnles or lines without the texture(just white / whatever color I specify). Is there anyway to just unbind the texture or do I have to create an all white texture and bind that? -THACO

Share this post


Link to post
Share on other sites
Advertisement
Either call glDisable(GL_TEXTURE_2D) to turn texturing off, or call glBindTexture(GL_TEXTURE_2D, 0) to bind no texture (unbinding the current texture)...

Share this post


Link to post
Share on other sites
word of warning, binding 0 ISNT the same as disabling textures, someone on here got tripped up by that a while ago, always prefer to disable texturing rather than binding 0 to the texture unit

Share this post


Link to post
Share on other sites
A small question of my own, relating to that:

The way I understood it is that when you bind texture 0 (or NULL, as I prefer) it doesn't actually disable texturing, but instead treats it as if you're using an "empty" texture. It will still generate the interpolated tex coords per fragment and such. By actually disabling texturing it skips those calculations, and therefore can make your rendering faster. Am I correct? If so, how does that affect shaders, which often use texture coordinates to store calculated values?

Share this post


Link to post
Share on other sites
No, nothing like that at all, actually.

Think of 0 as the default texture object.

Back in OpenGL 1.0, there were no texture objects. There was just *a* texture, and all calls to glTexParameter, glTexImage2D, etc., affected it. If you wanted to use more than one texture in a scene, you had to continually reload the data (or store it in a display list, but then you couldn't modify it). Texture objects were introduced first as an extension and then promoted to the core 1.1 to allow for the more efficient management of multiple textures.

Because texture objects have been around for more than 10 years now and are widely used, people tend to think of them as *the* way to use textures in OpenGL (personally, I remember reading a Gamasutra article about texture objects, and being surprised halfway through that it was describing what I was already doing). But you don't have to use them, and if you make any texturing calls without having a texture object bound, they'll fall back to the old way of doing things.

So, as _the_phantom_ pointed out, although binding texture object 0 can seem equivalent to disabling texturing, if you happen to pass in image data and set the parameters such that the texture is complete in that state, you'll suddenly realize that they aren't actually equivalent. So yeah, just disable texturing when you don't want it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Toji
If so, how does that affect shaders, which often use texture coordinates to store calculated values?


[talking about GLSL, however I dont see why it should be different for the ARB interface]
It doesnt effect shaders at all because you dont have to glEnable(GL_TEXTURE_2D) to use textures in a shader anyways (something alot of people still do) also, the OGL implimentation should automatically work out which attributes you are using and map the built in ones correctly. Instead of thinking of them as 'texture coordinate attributes' you should think of them as 'generic attribtes which happen to have a conviniance set of functions to map to the standard built in OpenGL attributes'.

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!