Skip to main content
gamedev.net
🔒 Locked

quick glBindTexture question

Started by Kaze Dec 18, 2005 at 8:55 PM 3 replies 700+ views
Original Post
Kaze
Kaze

//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;
 }
}

RichardS
RichardS
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).
IronFox
IronFox
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.
zedzeek
zedzeek
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.