PDA

View Full Version : erving the value of ONLY ONE OpenGL State



xee
08-22-2003, 01:48 PM
when preserving the value of ONLY ONE OpenGL State - GL_BLEND Enable Bit for Example - which is better,
use PushAttrib(GL_ENABLE_BIT), Note that it'll push the value of many other OpenGL States which are not needed.
or use a GLint and do it manualy :
// before changing the value of the stateGLint glBlendIsEnabled = glIsEnabled(GL_BLEND);// some code that's might change the value of GL_BLEND Enable Bit...// after changing the value of the stateif (glBlendIsEnabled) glEnable(GL_BLEND);else glDisable(GL_BLEND);

Coriolis
08-22-2003, 05:00 PM
Neither. You know what state OpenGL is in because you put it in that state; just keep track of it yourself.

al_bob
08-22-2003, 09:21 PM
You know what state OpenGL is in because you put it in that state;
Not necessarily. You might be building (say) a library that plugs into a larger rendering system. In this case, you might be interested in restoring the GL state to what it was prior to the lib calls.


which is better,
use PushAttrib(GL_ENABLE_BIT), Note that it'll push the value of many other OpenGL States which are not needed.
or use a GLint and do it manualy :
Although this is highly platform dependent, I believe that get/setting the state manually would most probably be faster, as the driver most likely manages a copy of the state interally anyway.

To be sure, benchmark.