目标:(三十四)中的101
osg::State是osg封装的opengl状态机,是全局的。osg状态机会在各个StateSet中切换,以完成图形的绘制。
osg/State
/** Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,
* implements lazy state updating and provides accessors for querying the current state.
* The venerable Red Book says that "OpenGL is a state machine", and this class
* represents the OpenGL state in OSG. Furthermore, \c State also has other
* important features:
* - It works as a stack of states (see \c pushStateSet() and
* \c popStateSet()). Manipulating this stack of OpenGL states manually is
* seldom needed, since OSG does this in the most common situations.
* - It implements lazy state updating. This means that, if one requests a
* state change and that particular state is already in the requested state,
* no OpenGL call will be made. This ensures that the OpenGL pipeline is not
* stalled by unnecessary state changes.
* - It allows to query the current OpenGL state without calls to \c glGet*(),
* which typically stall the graphics pipeline (see, for instance,
* \c captureCurrentState() and \c getModelViewMatrix()).
*/
class OSG_EXPORT State : public Referenced
osg::StateSet是每一个图形节点的状态集,是opengl状态的子集,是局部的。
osg/StateSet
/** Stores a set of modes and attributes which represent a set of OpenGL state.
* Notice that a \c StateSet contains just a subset of the whole OpenGL state.
* <p>In OSG, each \c Drawable and each \c Node has a reference to a
* \c StateSet. These <tt>StateSet</tt>s can be shared between
* different <tt>Drawable</tt>s and <tt>Node</tt>s (that is, several
* <tt>Drawable</tt>s and <tt>Node</tt>s can reference the same \c StateSet).
* Indeed, this practice is recommended whenever possible,
* as this minimizes expensive state changes in t