CanvasWidget: get new GUI camera on reset.
This commit is contained in:
parent
b50ea6753b
commit
e8f4e25c8c
2 changed files with 12 additions and 2 deletions
|
@ -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 )
|
||||||
|
|
|
@ -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*);
|
||||||
|
|
Loading…
Reference in a new issue