diff --git a/include/osg/State b/include/osg/State index 0410c9d3d..f777a5c29 100644 --- a/include/osg/State +++ b/include/osg/State @@ -72,9 +72,13 @@ class SG_EXPORT State : public Referenced /** push stateset onto state stack.*/ void pushStateSet(const StateSet* dstate); - /** pop drawstate off state stack.*/ + /** pop stateset off state stack.*/ void popStateSet(); + /** pop all stateset's off state stack, ensuring its empty ready for the next frame. + * note, to return OpenGL to default state, one should do any state.popAllStatSets(); state.apply().*/ + void popAllStateSets(); + /** copy the modes and attributes which captures the current state.*/ void captureCurrentState(StateSet& stateset) const; diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 5c73cd701..8c6d16712 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -148,6 +148,11 @@ void State::pushStateSet(const StateSet* dstate) } } +void State::popAllStateSets() +{ + while (!_drawStateStack.empty()) popStateSet(); +} + void State::popStateSet() { if (_drawStateStack.empty()) return; diff --git a/src/osgProducer/ViewerEventHandler.cpp b/src/osgProducer/ViewerEventHandler.cpp index d59318c2e..145cf00a1 100644 --- a/src/osgProducer/ViewerEventHandler.cpp +++ b/src/osgProducer/ViewerEventHandler.cpp @@ -170,7 +170,7 @@ void ViewerEventHandler::StatsAndHelpDrawCallback::operator()( const Producer::C state.popStateSet(); - state.apply(); + //state.apply(); } diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index e4c5fa31d..93da72017 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -211,7 +211,7 @@ void SceneView::cull() } // we in theory should be able to be able to bypass reset, but we'll call it just incase. - _state->reset(); + //_state->reset(); _state->setFrameStamp(_frameStamp.get()); _state->setDisplaySettings(_displaySettings.get()); @@ -805,6 +805,9 @@ void SceneView::draw() _renderStage->drawPreRenderStages(*_state,previous); _renderStage->draw(*_state,previous); } + + // re apply the defalt OGL state. + _state->popAllStateSets(); GLenum errorNo = glGetError(); if (errorNo!=GL_NO_ERROR)