Added better control for cancel GraphicsThreads.

This commit is contained in:
Robert Osfield
2005-11-10 15:25:06 +00:00
parent b19c005178
commit c2f1527fe0
3 changed files with 172 additions and 39 deletions

View File

@@ -90,6 +90,22 @@ struct DrawOperation : public osg::GraphicsThread::Operation
osg::ref_ptr<osgUtil::SceneView> _sceneView;
};
struct CleanUpOperation : public osg::GraphicsThread::Operation
{
CleanUpOperation(osgUtil::SceneView* sceneView):
osg::GraphicsThread::Operation("CleanUp",false),
_sceneView(sceneView)
{
}
virtual void operator () (osg::GraphicsContext*)
{
_sceneView->releaseAllGLObjects();
_sceneView->flushAllDeletedGLObjects();
}
osg::ref_ptr<osgUtil::SceneView> _sceneView;
};
// main does the following steps to create a multi-thread, multiple camera/graphics context view of a scene graph.
//
@@ -346,8 +362,25 @@ int main( int argc, char **argv )
}
}
std::cout<<"Exiting application"<<std::endl;
// start clean up.
for(gitr = graphicsContextSet.begin();
gitr != graphicsContextSet.end();
++gitr)
{
osg::GraphicsContext* context = *gitr;
osg::GraphicsThread* thread = context->getGraphicsThread();
if (thread)
{
thread->removeAllOperations();
thread->setDone(true);
}
}
std::cout<<"Removed all operations"<<std::endl;
return 0;
}