Stack Overflow Asked by pprovins on December 11, 2021
Changing active textures is an expensive operation in OpenGL. I am in the process of optimizing some code by batching drawn objects by their needed textures. I have already implemented a fix for this problem on the application side but I am wanting an answer to a question that popped up while I did so.
Say I have the following code:
bindTexture(tex1);
draw();
changeSomeUniforms();
bindTexture(tex1); // I rebind the same texture as used above!
draw();
bindTexture(tex2);
draw();
Assuming all textures are getting bound to GL_TEXTURE0
, is OpenGL capable of ignoring the unnecessary rebind of tex1
without my intervention? Since the call does not change the state of OpenGL, does OpenGL ignore it?
I currently batch things by similar texture so the above is in my application like so:
bindTexture(tex1);
draw();
changeSomeUniforms();
draw();
bindTexture(tex2);
draw();
I wanted to know if OpenGL was smarter than me and did not rebind the same texture without my intervention?
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP