Sign in to follow this  
mr_leerman

Texture calls before & after glActiveTextureARB( GL_TEXTURE0_ARB )

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this