Added releaseGLObjects to NodeCallbacks, Drawable::DrawCallbacks and wired up
osgProducer to use it when doing cleanup_frame.
This commit is contained in:
@@ -483,6 +483,8 @@ void Drawable::releaseGLObjects(State* state) const
|
||||
{
|
||||
if (_stateset.valid()) _stateset->releaseGLObjects(state);
|
||||
|
||||
if (_drawCallback.valid()) _drawCallback->releaseGLObjects(state);
|
||||
|
||||
if (!_useDisplayList) return;
|
||||
|
||||
if (state)
|
||||
|
||||
@@ -494,6 +494,9 @@ void Node::dirtyBound()
|
||||
void Node::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
if (_stateset.valid()) _stateset->releaseGLObjects(state);
|
||||
if (_updateCallback.valid()) _updateCallback->releaseGLObjects(state);
|
||||
if (_eventCallback.valid()) _eventCallback->releaseGLObjects(state);
|
||||
if (_cullCallback.valid()) _cullCallback->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -276,20 +276,29 @@ void SimpleViewer::frameDrawTraversal()
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleViewer::cleanup()
|
||||
void SimpleViewer::releaseAllGLObjects()
|
||||
{
|
||||
for(EventHandlers::iterator hitr = _eventHandlers.begin();
|
||||
hitr != _eventHandlers.end();
|
||||
++hitr)
|
||||
{
|
||||
(*hitr)->releaseGLObjects(_sceneView->getState());
|
||||
}
|
||||
|
||||
if (_databasePager.valid())
|
||||
{
|
||||
// clear the database pager so its starts a fresh on the next update/cull/draw traversals
|
||||
_databasePager->clear();
|
||||
|
||||
// release the GL objects stored in the scene graph.
|
||||
_sceneView->releaseAllGLObjects();
|
||||
|
||||
// do a flush to delete all the OpenGL objects that have been deleted or released from the scene graph.
|
||||
_sceneView->flushAllDeletedGLObjects();
|
||||
}
|
||||
|
||||
// release the GL objects stored in the scene graph.
|
||||
_sceneView->releaseAllGLObjects();
|
||||
}
|
||||
|
||||
void SimpleViewer::cleanup()
|
||||
{
|
||||
releaseAllGLObjects();
|
||||
|
||||
// do a flush to delete all the OpenGL objects that have been deleted or released from the scene graph.
|
||||
_sceneView->flushAllDeletedGLObjects();
|
||||
}
|
||||
|
||||
@@ -972,3 +972,14 @@ void Viewer::getUsage(osg::ApplicationUsage& usage) const
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::cleanup_frame()
|
||||
{
|
||||
for(EventHandlerList::iterator itr = _eventHandlerList.begin();
|
||||
itr != _eventHandlerList.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->releaseGLObjects();
|
||||
}
|
||||
|
||||
OsgCameraGroup::cleanup_frame();
|
||||
}
|
||||
|
||||
@@ -104,6 +104,13 @@ public:
|
||||
|
||||
virtual void operator()( const Producer::Camera & camera);
|
||||
|
||||
void releaseGLObjects() const
|
||||
{
|
||||
{ for(TextList::const_iterator itr = _descriptionList.begin(); itr != _descriptionList.end(); ++itr) (*itr)->releaseGLObjects(); }
|
||||
{ for(TextList::const_iterator itr = _optionList.begin(); itr != _optionList.end(); ++itr) (*itr)->releaseGLObjects(); }
|
||||
{ for(TextList::const_iterator itr = _explanationList.begin(); itr != _explanationList.end(); ++itr) (*itr)->releaseGLObjects(); }
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
ViewerEventHandler* _veh;
|
||||
@@ -1238,3 +1245,8 @@ void ViewerEventHandler::getUsage(osg::ApplicationUsage& usage) const
|
||||
usage.addKeyboardMouseBinding("z","Start recording camera path.");
|
||||
usage.addKeyboardMouseBinding("Z","If recording camera path stop recording camera path, save to \"saved_animation.path\"\nThen restart camera from beginning on animation path");
|
||||
}
|
||||
|
||||
void ViewerEventHandler::releaseGLObjects(osg::State*) const
|
||||
{
|
||||
if (_statsAndHelpDrawCallback) _statsAndHelpDrawCallback->releaseGLObjects();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user