UnBind a texture

Started by
6 comments, last by Toji 18 years, 8 months ago
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
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)...
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Bingo, that worked thanks

-THACO
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
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?
// The user formerly known as Tojiro67445, formerly known as Toji [smile]
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.
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'.
Ah! Thank you both! Makes a lot more sense now.
// The user formerly known as Tojiro67445, formerly known as Toji [smile]

This topic is closed to new replies.

Advertisement