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()
|
||||
{
|
||||
_gui_camera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
|
||||
assert(_gui_camera.valid());
|
||||
|
||||
sc::Canvas::addPlacementFactory
|
||||
(
|
||||
"object",
|
||||
|
@ -99,12 +102,17 @@ void CanvasMgr::shutdown()
|
|||
|
||||
sc::Canvas::removePlacementFactory("object");
|
||||
sc::Canvas::removePlacementFactory("scenery-object");
|
||||
|
||||
_gui_camera = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
unsigned int
|
||||
CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
|
||||
{
|
||||
if( !canvas )
|
||||
return 0;
|
||||
|
||||
osg::Texture2D* tex = canvas->getTexture();
|
||||
if( !tex )
|
||||
return 0;
|
||||
|
@ -115,8 +123,9 @@ CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
|
|||
// if( contexts.empty() )
|
||||
// return 0;
|
||||
|
||||
static osg::Camera* guiCamera =
|
||||
flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
|
||||
osg::ref_ptr<osg::Camera> guiCamera;
|
||||
if( !_gui_camera.lock(guiCamera) )
|
||||
return 0;
|
||||
|
||||
osg::State* state = guiCamera->getGraphicsContext()->getState(); //contexts[0]->getState();
|
||||
if( !state )
|
||||
|
|
|
@ -44,6 +44,7 @@ class CanvasMgr:
|
|||
|
||||
protected:
|
||||
|
||||
osg::observer_ptr<osg::Camera> _gui_camera;
|
||||
SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit;
|
||||
|
||||
void handleModelReinit(SGPropertyNode*);
|
||||
|
|
Loading…
Reference in a new issue