Unbound the texture?

I’m using glInterleavedArrays & glDrawElements, with texcoords enabled. Every model has it’s material, but some has texture and some doesn’t. When model without tex. follows one that has it, previous tex. is still bound. How can I ‘unbound’ it without deleting. I tried glBindTexture(GL_TEXTURE_2D, 0) but it seems that it doesn’t work?

Just disable the texture: glDisable(GL_TEXTURE_2D), that way the bound texture is simply ignored

Of course. But that’ll be a lot of changing texture state. I want to avoid this. Maybe I can sort models regarding if they have texture or not, and then change enable state just once…
But, still want to know if binding default texture (name==0) should kick previous texture out?

I believe that binding tex 0 will unbind the current texture. However it is probably undefined behaviour to render with GL_TEXTURE_2D enabled if there is no bound texture, so you still should disable it. Binding and unbinding will be more expensive than enable/disable.

Binding to texture 0 will return you to the “unnamed” texture object, just like the days of OpenGL 1.0, so if you’ve not modified any texture parameters without first binding to a texture object, it will return you to the default texture state.

Originally posted by T:
Just disable the texture: glDisable(GL_TEXTURE_2D), that way the bound texture is simply ignored

You should really do it

Ok. I sort them, and now use only one glDisable.
Maybe this is another topic; need your oppinion about this:
Is it right to allow models (i.e. connected group of faces) to have more then one texture and/or material, or even for every face in model? Will it cause performance hits?
I’m asking this beacuse I wrote ASE loader, and there you can have submaterials that are indexed in faces. So every face can have it’s material. But when you have thousands of them, I don’t think it’s a good idea to blindely change material properties per face, when there’s lots of them with same material.
What is the general suggestion?

[This message has been edited by dare (edited 03-22-2003).]

You should sort the index face list so that you never revisit the same material. Basically you will have an index face list per material in that object.

Originally posted by T:
You should sort the index face list so that you never revisit the same material. Basically you will have an index face list per material in that object.

Thanks T. Thought so. I just wanted to know what is the practice in ‘real world’ applications.
Is it better to keep one mat. per model, or is it too much to ask?