View Full Version : The scope of state variables
12-21-2001, 06:40 AM
I wonder, does all state variables changes have immediate effect - i.e. effect all geometry defined afterwards? The answer is clearly yes for state variables such a glColor* but is it also true for other things such as the Perspective matrix or glClipPlane?
For instance, is it possible to use multiple projection matrixes within the same display frame or is some settings global to the full frame?
And can I use glClipPlanes for some geometry in the scene and not the rest by enabling and disabling at before and after drawing the affected geometry?
Jacob Marner, B.Sc.
State variables do not change unless you explicitly change them ... therefore they are are valid over frames. When you begin a new frame, I assume you call glLoadIdentity() - which resets the modelview matrix, but not the projection matrix. And yes, they apply immediately.
In answer to your other question - you can change any of the matrices during a frame - a very common example is using perspective and ortho views at the same time. Clip planes can be changed at will too.
[This message has been edited by Shag (edited 12-21-2001).]
12-21-2001, 07:12 AM
Thanks for answering. The answer sounds good! I assume this applies to virtually any state variable, so I can, say, mix different shading modes in the same scene.
How about performance; is state changes expensive? I am thinking that most implementations of OpenGL use some sort of pipeline and changing certain variable will need to flush the pipeline. Does it pay performancewise to use processing time at run-time to sort my geometry to minimize state changes?
You're absolutley correct. State changes are expensive, so avoid them as much as possible. And as you said, if you sort geometry to minimise state changes, you will see certainly see improved performance.
12-21-2001, 07:32 AM
Thanks again. As you might have guessed I am new to OpenGL but not to graphics programming in general.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.