Preserving the value of ONLY ONE OpenGL State ?

Started by
1 comment, last by Xeee 20 years, 8 months ago
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 state

GLint glBlendIsEnabled = glIsEnabled(GL_BLEND);
// some code that''s might change the value of GL_BLEND Enable Bit

...
// after changing the value of the state

if (glBlendIsEnabled)
	glEnable(GL_BLEND);
else
	glDisable(GL_BLEND);
xee..
xee..
Advertisement
Do it on your own! And save the current state values also by your own, because glIsEnabled could be slow down everything if it is called too often.
There was a big discussion on this quite a while ago (I can''t find the thread tho). I think it was generally decided that the driver will cache the state if it would be expensive to check it on the card, so doing it yourself:

i) doesn''t hurt unless you do the check twice (i.e. if you''re performing work the driver does)

ii) doesn''t add any performance gain

I''ve never seen any evidence that glIsEnabled slows things down so I''d be interested to see your evidence Austrian Coder.

This topic is closed to new replies.

Advertisement