• Advertisement
Sign in to follow this  

Texture calls before & after glActiveTextureARB( GL_TEXTURE0_ARB )

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

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement