diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index e5d043249..32be9af2f 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -414,6 +414,11 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSetting /** Do draw traversal of draw bins generated by cull traversal.*/ virtual void draw(); + /** Releast all OpenGL objects from the scene graph, such as texture objects, display lists etc. + * These released scene graphs placed in the respective delete GLObjects cache, which + * then need to be deleted in OpenGL by SceneView::flushAllDeleteGLObjects(). */ + virtual void releaseAllGLObjects(); + /** Flush all deleted OpenGL objects, such as texture objects, display lists etc.*/ virtual void flushAllDeletedGLObjects(); diff --git a/src/osgUtil/GLObjectsVisitor.cpp b/src/osgUtil/GLObjectsVisitor.cpp index 6008c5c05..e07256ef3 100644 --- a/src/osgUtil/GLObjectsVisitor.cpp +++ b/src/osgUtil/GLObjectsVisitor.cpp @@ -12,6 +12,7 @@ */ #include #include +#include using namespace osg; using namespace osgUtil; @@ -88,6 +89,7 @@ void GLObjectsVisitor::apply(osg::StateSet& stateset) } if (_mode&RELEASE_STATE_ATTRIBUTES) { + osg::notify(osg::NOTICE)<<"GLObjectsVisitor::apply"<prune(); } +void SceneView::releaseAllGLObjects() +{ + if (!_sceneData) return; + + GLObjectsVisitor globjv(GLObjectsVisitor::RELEASE_DISPLAY_LISTS|GLObjectsVisitor::RELEASE_STATE_ATTRIBUTES); + globjv.setNodeMaskOverride(0xffffffff); + globjv.setState(_state.get()); + _sceneData->accept(globjv); +} + void SceneView::flushAllDeletedGLObjects() {