PDA

View Full Version : "Sealed" OpenGL Command Blocks ?



pontifikas
09-10-2009, 06:28 AM
Is there a way to issue a batch of commands in OpenGL which have no effect to the outside world, just like Push-Pop Matrix.

For example, I want my Rendering environment to have a specified Fill mode(Solid,wire,point). But I want each individual 3D objects to override it if they wish. In order to do that, I have to issue glPolygonMode before drawing the object that want fill mode different to that of the environment. After the drawing command I have to issue glPolygonMode again to restore the environments Fill Mode.

Is there a way to avoid issuing twice such commands?

Thank you.

Dark Photon
09-10-2009, 07:07 AM
Is there a way to issue a batch of commands in OpenGL which have no effect to the outside world, just like Push-Pop Matrix ... glPolygonMode before drawing ... glPolygonMode again to restore the environments Fill Mode.

Is there a way to avoid issuing twice such commands?
There is glPushAttrib/glPopAttrib, but the usual way is to do lazy state. That is have application "lazy state" wrappers around the GL state setting that only changes state if you know its changed.

k_szczech
09-10-2009, 07:50 AM
If you want to avoid multiple state switches, then just sort your objects by state.
First draw objects that use the global setting, then draw objects that use custom setting.