Jump to content
  • Advertisement
Sign in to follow this  
Kaze

quick glBindTexture question

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

//will 
glBindTexture(GL_TEXTURE_2D,texture);
//not take as long if the selected texture is already binded or should i just

Gluint CurrentTexture=0;

void bind(Gluint texture){
 if (texture!=CurrentTexture){
  glBindTexture(GL_TEXTURE_2D,texture);
  CurrentTexture=texture;
 }
}

Share this post


Link to post
Share on other sites
Advertisement
That is entirely dependant on the implementation that you are using. I assume that any reasonable implementation would not re-bind a texture that is already bound (so the performance hit shouldn't be much more than the function call overhead).

Share this post


Link to post
Share on other sites
I used to do that too. Until i did a performance-check. On the hardware i was using at that time it didn't matter at all.
I assume common implementations check the currently bound texture before binding anyway. So the client-application is not required to perform this check.
But I may be wrong and not checking might slow down some machines. Then again chances that you exidentially bind the same texture twice in a row is really low.

Share this post


Link to post
Share on other sites
its slower on all hardware, u most likely didnt see a difference cause both take very little time eg perhaps 0.0000001 secs thus its hard to tell the differences

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!