OpenGL Whether to turn GL_BLEND on/off all the time

Question:

when transparent objects are drawn, GL_BLEND is turned on, when drawing ends, GL_BLEND is turned off. Maybe you don't need to turn it off, turn it on once when you start the program and that's it? How does constant on/off affect performance?

Answer:

How does constant on/off affect performance?

Yes, any function that changes the context first waits for the GPU to be ready, and then freezes both the CPU and the GPU until the changes are transferred.

Maybe you don't need to turn it off, turn it on once when you start the program and that's it?

If your context is no longer used (and in most cases it is), then there is no need to restore the settings. In addition, the operating system itself saves them before accessing another OpenGL application and restores them back when it returns to you.

Scroll to Top