Texture calls before & after glActiveTextureARB( GL_TEXTURE0_ARB )

Started by
2 comments, last by vincoof 19 years, 8 months ago
Am I right in assuming that making the following texturing calls: #1

GLuint t_NewTexHandle;
glGenTextures( 1, &t_NewTexHandle );
glBindTexture( GL_TEXTURE_2D, t_NewTexHandle );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
..etc...
#2

glActiveTextureARB(GL_TEXTURE0_ARB);
GLuint t_NewTexHandle;
glGenTextures( 1, &t_NewTexHandle );
glBindTexture( GL_TEXTURE_2D, t_NewTexHandle );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
..etc...
alter the same internal settings? That is, is Texture Unit 0 changed when you make texturing calls without specifying a Texture Unit via glActiveTextureARB? ie Is it the default Texture Unit?
---Phear the hamsters!
Advertisement
Texture unit 0 is the default texture unit, yes, but that doesn't mean the two codes are always equal. Code #2 will always bind the texture to the first texture unit, since you explicitly activate that unit right before binding the texture. Code #1 will bind the texture to whatever unit is active, which by default is the first one. But if you for some reason change the active texture unit in some other part of the code, another unit may be active.
Thanks Brother Bob, that's exactly what I needed to know :)

(Yes, I was assuming that no other Texture Unit would be made active before code #1.)
---Phear the hamsters!
If you're unsure which texture unit will be active before calling this piece of code, you should always call glActiveTextureARB. This will be (almost) free in all OpenGL implementations, and will prevent from side effects.

This topic is closed to new replies.

Advertisement