diff --git a/include/osg/Drawable b/include/osg/Drawable index deeddd0d0..c224907a8 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -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 diff --git a/include/osg/Geode b/include/osg/Geode index 67e647d69..4d258c64d 100644 --- a/include/osg/Geode +++ b/include/osg/Geode @@ -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.*/ diff --git a/include/osg/Material b/include/osg/Material index f9249b942..89912c512 100644 --- a/include/osg/Material +++ b/include/osg/Material @@ -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. diff --git a/include/osgParticle/PrecipitationEffect b/include/osgParticle/PrecipitationEffect index 8b1d12f01..f2aecbd7b 100644 --- a/include/osgParticle/PrecipitationEffect +++ b/include/osgParticle/PrecipitationEffect @@ -192,7 +192,7 @@ namespace osgParticle virtual ~PrecipitationEffect() {} - void compileGLObjects(osg::State& state) const; + void compileGLObjects(osg::RenderInfo& renderInfo) const; void update(); diff --git a/include/osgUtil/GLObjectsVisitor b/include/osgUtil/GLObjectsVisitor index 982d44078..c88a2a14d 100644 --- a/include/osgUtil/GLObjectsVisitor +++ b/include/osgUtil/GLObjectsVisitor @@ -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 StatesSetAppliedSet; Mode _mode; - osg::ref_ptr _state; + osg::RenderInfo _renderInfo; DrawableAppliedSet _drawablesAppliedSet; StatesSetAppliedSet _stateSetAppliedSet; diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index eaec82412..6f6171b02 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -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(); diff --git a/src/osg/Geode.cpp b/src/osg/Geode.cpp index 173ef4e3a..c2b2fafc1 100644 --- a/src/osg/Geode.cpp +++ b/src/osg/Geode.cpp @@ -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); } } diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 26725d22a..732ebe60f 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -867,6 +867,9 @@ void DatabasePager::compileGLObjects(osg::State& state, double& availableTime) { // osg::notify(osg::NOTICE)<<"DatabasePager::compileGLObjects "<<_frameNumber<0.0) { @@ -971,7 +974,7 @@ void DatabasePager::compileGLObjects(osg::State& state, double& availableTime) { //osg::notify(osg::INFO)<<" Compiling drawable "<<(*itr).get()<compileGLObjects(state); + (*itr)->compileGLObjects(renderInfo); elapsedTime = timer.delta_s(start_tick,timer.tick()); // estimate the duration of the compile based on current compile duration. diff --git a/src/osgParticle/ConnectedParticleSystem.cpp b/src/osgParticle/ConnectedParticleSystem.cpp index f8823b79a..1138e830f 100644 --- a/src/osgParticle/ConnectedParticleSystem.cpp +++ b/src/osgParticle/ConnectedParticleSystem.cpp @@ -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) { } diff --git a/src/osgParticle/PrecipitationEffect.cpp b/src/osgParticle/PrecipitationEffect.cpp index 1e6aa2620..499a3f4b8 100644 --- a/src/osgParticle/PrecipitationEffect.cpp +++ b/src/osgParticle/PrecipitationEffect.cpp @@ -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()); } } diff --git a/src/osgUtil/GLObjectsVisitor.cpp b/src/osgUtil/GLObjectsVisitor.cpp index eb0ec5c77..462f4bc5a 100644 --- a/src/osgUtil/GLObjectsVisitor.cpp +++ b/src/osgUtil/GLObjectsVisitor.cpp @@ -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()); } }