is glBindTexture expensive ?

what is better ?


if (texture != activeTexture) {
activeTexture = texture;

I have heard somewhere that glBindTexture is somewhat expensive, so probably option 2 is better, but I also have heard that the extra if is yet more expensive… so which one is true ?


2 is faster

or 3) sort objects by the most expensive state changes (may be the texture bind, but could be program bind, lighting on/off, etc…) and don’t change that state until you have to.

#2 improves on #1 on average. But if your scene ping-pongs between two or more textures (e.g., ABABAB…), you’re no better off.

Does the same apply to glActiveTexture?

Also keep in mind that option 2 might affect depending on the size of texture.

If you are loading very small textures (1MB or so) throughout your program then OpenGL driver already will have copy in memory and overall cost would be far less than loading first time.