Added mutexes to RealizeCallbaks

This commit is contained in:
Robert Osfield 2006-07-19 13:02:35 +00:00
parent 4bb4add9b3
commit b03a772846
2 changed files with 25 additions and 12 deletions

View File

@ -1359,14 +1359,19 @@ class CompileStateCallback : public osgProducer::OsgCameraGroup::RealizeCallback
{
// now safe to construct
sh.init();
if (_gameEventHandler)
{
_gameEventHandler->compileGLObjects(*(sh.getSceneView()->getState()));
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (_gameEventHandler)
{
_gameEventHandler->compileGLObjects(*(sh.getSceneView()->getState()));
}
}
}
OpenThreads::Mutex _mutex;
GameEventHandler* _gameEventHandler;
};

View File

@ -101,23 +101,31 @@ class ConstructStateCallback : public osgProducer::OsgCameraGroup::RealizeCallba
}
virtual void operator()( osgProducer::OsgCameraGroup&, osgProducer::OsgSceneHandler& sh, const Producer::RenderSurface& )
{
if (!_initialized)
{
{
// only initialize state once, only need for cases where multiple graphics contexts are
// if which case this callback can get called multiple times.
_initialized = true;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (_node) _node->setStateSet(constructState());
}
if (!_initialized)
{
// only initialize state once, only need for cases where multiple graphics contexts are
// if which case this callback can get called multiple times.
_initialized = true;
if (_node) _node->setStateSet(constructState());
}
}
// now safe to con
sh.init();
}
osg::Node* _node;
bool _initialized;
OpenThreads::Mutex _mutex;
osg::Node* _node;
bool _initialized;
};