Added mutexes to RealizeCallbaks
This commit is contained in:
parent
4bb4add9b3
commit
b03a772846
@ -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;
|
||||
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user