osgEarth的Rex引擎原理分析(四十一)osg::State和osg::StateSet的关系

本文详细分析了osgEarth中的osg::State和osg::StateSet的关系。osg::State作为全局的OpenGL状态机,负责在不同StateSet之间切换,以满足图形绘制需求。而osg::StateSet则是个体图形节点的状态集合,是OpenGL状态的子集,具有局部性。文章列举了一系列后续将要探讨的osgEarth相关问题,涵盖地理信息引擎、地形引擎、瓦片加载和资源管理等多个方面。
摘要由CSDN通过智能技术生成

目标:(三十四)中的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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值