1
0
Fork 0

CanvasWidget: get new GUI camera on reset.

This commit is contained in:
Thomas Geymayer 2013-12-01 12:57:14 +01:00
parent b50ea6753b
commit e8f4e25c8c
2 changed files with 12 additions and 2 deletions

View file

@ -75,6 +75,9 @@ CanvasMgr::CanvasMgr():
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void CanvasMgr::init() void CanvasMgr::init()
{ {
_gui_camera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
assert(_gui_camera.valid());
sc::Canvas::addPlacementFactory sc::Canvas::addPlacementFactory
( (
"object", "object",
@ -99,12 +102,17 @@ void CanvasMgr::shutdown()
sc::Canvas::removePlacementFactory("object"); sc::Canvas::removePlacementFactory("object");
sc::Canvas::removePlacementFactory("scenery-object"); sc::Canvas::removePlacementFactory("scenery-object");
_gui_camera = 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
unsigned int unsigned int
CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
{ {
if( !canvas )
return 0;
osg::Texture2D* tex = canvas->getTexture(); osg::Texture2D* tex = canvas->getTexture();
if( !tex ) if( !tex )
return 0; return 0;
@ -115,8 +123,9 @@ CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
// if( contexts.empty() ) // if( contexts.empty() )
// return 0; // return 0;
static osg::Camera* guiCamera = osg::ref_ptr<osg::Camera> guiCamera;
flightgear::getGUICamera(flightgear::CameraGroup::getDefault()); if( !_gui_camera.lock(guiCamera) )
return 0;
osg::State* state = guiCamera->getGraphicsContext()->getState(); //contexts[0]->getState(); osg::State* state = guiCamera->getGraphicsContext()->getState(); //contexts[0]->getState();
if( !state ) if( !state )

View file

@ -44,6 +44,7 @@ class CanvasMgr:
protected: protected:
osg::observer_ptr<osg::Camera> _gui_camera;
SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit; SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit;
void handleModelReinit(SGPropertyNode*); void handleModelReinit(SGPropertyNode*);