diff --git a/src/Canvas/gui_mgr.cxx b/src/Canvas/gui_mgr.cxx index 6e6db2b3b..774afe622 100644 --- a/src/Canvas/gui_mgr.cxx +++ b/src/Canvas/gui_mgr.cxx @@ -116,7 +116,7 @@ class DesktopGroup: public sc::Group { public: - DesktopGroup(osgViewer::View* view); + DesktopGroup(osg::Camera* camera); void setFocusWindow(const sc::WindowPtr& window); @@ -202,7 +202,7 @@ bool GUIEventHandler::handle( const osgEA& ea, } //------------------------------------------------------------------------------ -DesktopGroup::DesktopGroup(osgViewer::View* view): +DesktopGroup::DesktopGroup(osg::Camera* camera): Group(sc::CanvasPtr(), fgGetNode("/sim/gui/canvas", true)), _cb_mouse_mode( this, &DesktopGroup::handleMouseMode, @@ -210,7 +210,6 @@ DesktopGroup::DesktopGroup(osgViewer::View* view): _width(_node, "size[0]"), _height(_node, "size[1]") { - auto camera = view->getCamera(); if( !camera ) { SG_LOG(SG_GUI, SG_WARN, "DesktopGroup: failed to get GUI camera."); @@ -642,9 +641,10 @@ GUIMgr::GUIMgr() } //------------------------------------------------------------------------------ -void GUIMgr::setGUIView(osgViewer::View* view) +void GUIMgr::setGUIViewAndCamera(osgViewer::View* view, osg::Camera* cam) { _viewerView = view; + _camera = cam; } //------------------------------------------------------------------------------ @@ -666,7 +666,12 @@ void GUIMgr::init() return; } - DesktopPtr desktop( new DesktopGroup(_viewerView) ); + auto camera = _camera; + if (!camera) { + camera = _viewerView->getCamera(); + } + + DesktopPtr desktop( new DesktopGroup(camera) ); desktop->handleResize ( 0, diff --git a/src/Canvas/gui_mgr.hxx b/src/Canvas/gui_mgr.hxx index 0abf86887..735fcdfa3 100644 --- a/src/Canvas/gui_mgr.hxx +++ b/src/Canvas/gui_mgr.hxx @@ -29,6 +29,8 @@ #include namespace osgViewer { class View; } +namespace osg { class Camera; } + namespace osgGA { class GUIEventAdapter; @@ -72,13 +74,14 @@ public: void ungrabPointer(const simgear::canvas::WindowPtr& window); /** - * specify the osgViewer::View which contains the GUI. + * specify the osgViewer::View and Camera */ - void setGUIView(osgViewer::View* view); + void setGUIViewAndCamera(osgViewer::View* view, osg::Camera* cam); protected: simgear::canvas::GroupPtr _desktop; osg::ref_ptr _event_handler; - osg::ref_ptr _viewerView;; + osg::ref_ptr _viewerView; + osg::ref_ptr _camera; simgear::canvas::Placements addWindowPlacement( SGPropertyNode* placement, diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 3244670cd..63b3cf74f 100755 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1106,7 +1106,8 @@ void fgCreateSubsystems(bool duringReset) { auto canvasGui = new GUIMgr; globals->add_subsystem("CanvasGUI", canvasGui, SGSubsystemMgr::DISPLAY); - canvasGui->setGUIView(globals->get_renderer()->getView()); + auto guiCamera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault()); + canvasGui->setGUIViewAndCamera(globals->get_renderer()->getView(), guiCamera); #ifdef ENABLE_AUDIO_SUPPORT globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);