glActiveTexture and glBindTexture

Started by
1 comment, last by arka80 10 years, 2 months ago

I thought that a glBindTexture following a glActiveTexture would cause the texture to be binded in the texture order specified by the glActiveTexture, but according to my experiments it's not.

Example:


glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texID);
// draw something using GL_TEXTURE0... it uses texture texID

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, anotherTexID);
// draw something using GL_TEXTURE0 again... it uses anotherTexID!

texID is binded to GL_TEXTURE0 ? and anotherTexID to GL_TEXTURE1? I think not, because second draw will use the second texture even if I tell to use GL_TEXURE0 (the first).

So it's true? glBind is not related to glActive and viceversa?

Advertisement

This depends on what texture environment (via glTexEnv - for fixed pipeline OpenGL) or shader (for modern OpenGL) you've set. In other words - glBindTexture does set the texture for the currently active texture unit, but this just sets the inputs for your drawing. It's also up to you to tell OpenGL what to actually do with those inputs.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

thank for reply, I use shaders.

Anyway, this morning, after visual studio restart and a clean and rebuild (or maybe a night of sleep), it works as aspected, with the second call using the second texture. I hope this will never happens again! Yesterday I tried so many times! mah wacko.png

This topic is closed to new replies.

Advertisement