PDA

View Full Version : Binding textures



enmaniac
11-29-2005, 06:37 AM
Hi!

One of the optimiazions which can be done to speed up rendering is to sort the objects with respect to texture. Fewer the texture changes faster the rendering is.

Lets assume the following scenario:

glBindTexture( GL_TEXTURE_2D, 1 );
drawSth(...);

glBindTexture( GL_TEXTURE_2D, 1 );
drawSthElse(...);
Will the second glBindTexture impact the performace ? Will the OGL notice that the texture 1 is already binded and needs no binding ? Or should I take care of checking what texture has been previously binded and prevent calling glBindTexture ?

Thx in advance

Relic
11-29-2005, 08:20 AM
The call alone is slower than a simple if-statement!
All those state changing OpenGL entrypoints need to do error checking on the parameters before they can advance to compare current state with desired state, that costs more than your if-statements required to check if the texture object id has changed.
So yes, depending on the amount of geometry in your drawing calls, this could have a measurable impact.

enmaniac
11-30-2005, 12:19 AM
Thank you Relic!