Further migration to using RenderInfo
This commit is contained in:
@@ -276,7 +276,7 @@ class OSG_EXPORT Drawable : public Object
|
||||
/** Immediately compile this \c Drawable into an OpenGL Display List.
|
||||
* @note Operation is ignored if \c _useDisplayList is \c false.
|
||||
*/
|
||||
virtual void compileGLObjects(State& state) const;
|
||||
virtual void compileGLObjects(RenderInfo& renderInfo) const;
|
||||
|
||||
/** If State is non-zero, this function releases OpenGL objects for
|
||||
* the specified graphics context. Otherwise, releases OpenGL objexts
|
||||
|
||||
@@ -126,7 +126,7 @@ class OSG_EXPORT Geode : public Node
|
||||
const DrawableList& getDrawableList() const { return _drawables; }
|
||||
|
||||
/** Compile OpenGL Display List for each drawable.*/
|
||||
void compileDrawables(State& state);
|
||||
void compileDrawables(RenderInfo& renderInfo);
|
||||
|
||||
/** Return the Geode's bounding box, which is the union of all the
|
||||
* bounding boxes of the geode's drawables.*/
|
||||
|
||||
@@ -77,7 +77,7 @@ class OSG_EXPORT Material : public StateAttribute
|
||||
|
||||
Material& operator = (const Material& rhs);
|
||||
|
||||
virtual bool getModeUsage(ModeUsage& usage) const
|
||||
virtual bool getModeUsage(ModeUsage& /*usage*/) const
|
||||
{
|
||||
// note, since Material does it's own glEnable/glDisable of GL_COLOR_MATERIAL
|
||||
// we shouldn't declare usage of that mode, so commenting out the below usage.
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace osgParticle
|
||||
|
||||
virtual ~PrecipitationEffect() {}
|
||||
|
||||
void compileGLObjects(osg::State& state) const;
|
||||
void compileGLObjects(osg::RenderInfo& renderInfo) const;
|
||||
|
||||
void update();
|
||||
|
||||
|
||||
@@ -71,14 +71,23 @@ class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor
|
||||
/** Set the State to use during traversal. */
|
||||
void setState(osg::State* state)
|
||||
{
|
||||
_state = state;
|
||||
_renderInfo.setState(state);
|
||||
}
|
||||
|
||||
osg::State* getState()
|
||||
{
|
||||
return _state.get();
|
||||
return _renderInfo.getState();
|
||||
}
|
||||
|
||||
void setRenderInfo(osg::RenderInfo& renderInfo)
|
||||
{
|
||||
_renderInfo = renderInfo;
|
||||
}
|
||||
|
||||
osg::RenderInfo& getRenderInfo()
|
||||
{
|
||||
return _renderInfo;
|
||||
}
|
||||
|
||||
/** Simply traverse using standard NodeVisitor traverse method.*/
|
||||
virtual void apply(osg::Node& node);
|
||||
@@ -97,7 +106,7 @@ class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor
|
||||
typedef std::set<osg::StateSet*> StatesSetAppliedSet;
|
||||
|
||||
Mode _mode;
|
||||
osg::ref_ptr<osg::State> _state;
|
||||
osg::RenderInfo _renderInfo;
|
||||
DrawableAppliedSet _drawablesAppliedSet;
|
||||
StatesSetAppliedSet _stateSetAppliedSet;
|
||||
|
||||
|
||||
@@ -450,13 +450,13 @@ void Drawable::dirtyBound()
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::compileGLObjects(State& state) const
|
||||
void Drawable::compileGLObjects(RenderInfo& renderInfo) const
|
||||
{
|
||||
if (!_useDisplayList) return;
|
||||
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
unsigned int contextID = state.getContextID();
|
||||
unsigned int contextID = renderInfo.getContextID();
|
||||
|
||||
// get the globj for the current contextID.
|
||||
GLuint& globj = _globjList[contextID];
|
||||
@@ -471,9 +471,9 @@ void Drawable::compileGLObjects(State& state) const
|
||||
glNewList( globj, GL_COMPILE );
|
||||
|
||||
if (_drawCallback.valid())
|
||||
_drawCallback->drawImplementation(state,this);
|
||||
_drawCallback->drawImplementation(renderInfo,this);
|
||||
else
|
||||
drawImplementation(state);
|
||||
drawImplementation(renderInfo);
|
||||
|
||||
glEndList();
|
||||
|
||||
|
||||
@@ -199,13 +199,13 @@ BoundingSphere Geode::computeBound() const
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
void Geode::compileDrawables(State& state)
|
||||
void Geode::compileDrawables(RenderInfo& renderInfo)
|
||||
{
|
||||
for(DrawableList::iterator itr = _drawables.begin();
|
||||
itr!=_drawables.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->compileGLObjects(state);
|
||||
(*itr)->compileGLObjects(renderInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -867,6 +867,9 @@ void DatabasePager::compileGLObjects(osg::State& state, double& availableTime)
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"DatabasePager::compileGLObjects "<<_frameNumber<<std::endl;
|
||||
|
||||
osg::RenderInfo renderInfo;
|
||||
renderInfo.setState(&state);
|
||||
|
||||
if (availableTime>0.0)
|
||||
{
|
||||
|
||||
@@ -971,7 +974,7 @@ void DatabasePager::compileGLObjects(osg::State& state, double& availableTime)
|
||||
{
|
||||
//osg::notify(osg::INFO)<<" Compiling drawable "<<(*itr).get()<<std::endl;
|
||||
double startCompileTime = timer.delta_s(start_tick,timer.tick());
|
||||
(*itr)->compileGLObjects(state);
|
||||
(*itr)->compileGLObjects(renderInfo);
|
||||
elapsedTime = timer.delta_s(start_tick,timer.tick());
|
||||
|
||||
// estimate the duration of the compile based on current compile duration.
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
using namespace osgParticle;
|
||||
|
||||
ConnectedParticleSystem::ConnectedParticleSystem():
|
||||
_startParticle(Particle::INVALID_INDEX),
|
||||
_lastParticleCreated(Particle::INVALID_INDEX),
|
||||
_maxNumberOfParticlesToSkip(200)
|
||||
_maxNumberOfParticlesToSkip(200),
|
||||
_startParticle(Particle::INVALID_INDEX)
|
||||
{
|
||||
}
|
||||
|
||||
ConnectedParticleSystem::ConnectedParticleSystem(const ConnectedParticleSystem& copy, const osg::CopyOp& copyop):
|
||||
ParticleSystem(copy,copyop),
|
||||
_startParticle(copy._startParticle),
|
||||
_lastParticleCreated(copy._lastParticleCreated),
|
||||
_maxNumberOfParticlesToSkip(200)
|
||||
_maxNumberOfParticlesToSkip(200),
|
||||
_startParticle(copy._startParticle)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -168,24 +168,24 @@ PrecipitationEffect::PrecipitationEffect(const PrecipitationEffect& copy, const
|
||||
update();
|
||||
}
|
||||
|
||||
void PrecipitationEffect::compileGLObjects(osg::State& state) const
|
||||
void PrecipitationEffect::compileGLObjects(osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
if (_quadGeometry.valid())
|
||||
{
|
||||
_quadGeometry->compileGLObjects(state);
|
||||
if (_quadGeometry->getStateSet()) _quadGeometry->getStateSet()->compileGLObjects(state);
|
||||
_quadGeometry->compileGLObjects(renderInfo);
|
||||
if (_quadGeometry->getStateSet()) _quadGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
||||
}
|
||||
|
||||
if (_lineGeometry.valid())
|
||||
{
|
||||
_lineGeometry->compileGLObjects(state);
|
||||
if (_lineGeometry->getStateSet()) _lineGeometry->getStateSet()->compileGLObjects(state);
|
||||
_lineGeometry->compileGLObjects(renderInfo);
|
||||
if (_lineGeometry->getStateSet()) _lineGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
||||
}
|
||||
|
||||
if (_pointGeometry.valid())
|
||||
{
|
||||
_pointGeometry->compileGLObjects(state);
|
||||
if (_pointGeometry->getStateSet()) _pointGeometry->getStateSet()->compileGLObjects(state);
|
||||
_pointGeometry->compileGLObjects(renderInfo);
|
||||
if (_pointGeometry->getStateSet()) _pointGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ void PrecipitationEffect::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (globjVisitor->getMode() & osgUtil::GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES)
|
||||
{
|
||||
compileGLObjects(*(globjVisitor->getState()));
|
||||
compileGLObjects(globjVisitor->getRenderInfo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ GLObjectsVisitor::GLObjectsVisitor(Mode mode)
|
||||
|
||||
_mode = mode;
|
||||
|
||||
_state = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,14 +73,14 @@ void GLObjectsVisitor::apply(osg::Drawable& drawable)
|
||||
drawable.setUseDisplayList(true);
|
||||
}
|
||||
|
||||
if (_mode&COMPILE_DISPLAY_LISTS && _state.valid())
|
||||
if (_mode&COMPILE_DISPLAY_LISTS && _renderInfo.getState())
|
||||
{
|
||||
drawable.compileGLObjects(*_state);
|
||||
drawable.compileGLObjects(_renderInfo);
|
||||
}
|
||||
|
||||
if (_mode&RELEASE_DISPLAY_LISTS)
|
||||
{
|
||||
drawable.releaseGLObjects(_state.get());
|
||||
drawable.releaseGLObjects(_renderInfo.getState());
|
||||
}
|
||||
|
||||
if (_mode&SWITCH_ON_VERTEX_BUFFER_OBJECTS)
|
||||
@@ -101,18 +100,18 @@ void GLObjectsVisitor::apply(osg::StateSet& stateset)
|
||||
|
||||
_stateSetAppliedSet.insert(&stateset);
|
||||
|
||||
if (_mode & COMPILE_STATE_ATTRIBUTES && _state.valid())
|
||||
if (_mode & COMPILE_STATE_ATTRIBUTES && _renderInfo.getState())
|
||||
{
|
||||
stateset.compileGLObjects(*_state);
|
||||
stateset.compileGLObjects(*_renderInfo.getState());
|
||||
}
|
||||
|
||||
if (_mode & RELEASE_STATE_ATTRIBUTES)
|
||||
{
|
||||
stateset.releaseGLObjects(_state.get());
|
||||
stateset.releaseGLObjects(_renderInfo.getState());
|
||||
}
|
||||
|
||||
if (_mode & CHECK_BLACK_LISTED_MODES)
|
||||
{
|
||||
stateset.checkValidityOfAssociatedModes(*_state.get());
|
||||
stateset.checkValidityOfAssociatedModes(*_renderInfo.getState());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user