]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/panelnode.cxx
Initial commit of the new sound system, expect more updates to follow
[flightgear.git] / src / Model / panelnode.cxx
index 29b4d0e725a4a1d29222be9db25c3995c56ad925..6ac60caaaeb7b41b16b3b70d2526ecd4c6a78e4f 100644 (file)
@@ -3,15 +3,15 @@
 #endif
 
 #include <simgear/compiler.h>
-#include <vector>
+#include <simgear/structure/exception.hxx>
 
-#include <plib/sg.h>
+#include <vector>
 
 #include <Cockpit/panel.hxx>
 #include <Cockpit/panel_io.hxx>
 #include "panelnode.hxx"
 
-SG_USING_STD(vector);
+using std::vector;
 
 
 // Static (!) handling for all 3D panels in the program.
@@ -41,7 +41,10 @@ FGPanelNode::FGPanelNode(SGPropertyNode* props)
 
     // Make an FGPanel object.  But *don't* call init() or bind() on
     // it -- those methods touch static state.
-    _panel = fgReadPanel(props->getStringValue("path"));
+    const char *path = props->getStringValue("path");
+    _panel = fgReadPanel(path);
+    if (!_panel)
+        throw sg_io_exception(string("Failed to load panel ") + path);
 
     // Never mind.  We *have* to call init to make sure the static
     // state is initialized (it's not, if there aren't any 2D
@@ -125,12 +128,14 @@ FGPanelNode::drawImplementation(osg::State& state) const
   // coordinates to panel coordinates when the user clicks the
   // mouse.
   // OSGFIXME: we don't need that when we can really pick
-  const_cast<osg::Matrix&>(_lastModelview) = state.getModelViewMatrix();
-  const_cast<osg::Matrix&>(_lastProjection) = state.getProjectionMatrix();
-  state.getCurrentViewport()->getViewport(const_cast<int&>(_lastViewport[0]),
-                                          const_cast<int&>(_lastViewport[1]),
-                                          const_cast<int&>(_lastViewport[2]),
-                                          const_cast<int&>(_lastViewport[3]));
+  _lastModelview = state.getModelViewMatrix();
+  _lastProjection = state.getProjectionMatrix();
+
+  const osg::Viewport* vp = state.getCurrentViewport();
+  _lastViewport[0] = vp->x();
+  _lastViewport[1] = vp->y();
+  _lastViewport[2] = vp->width();
+  _lastViewport[3] = vp->height();
   
   _panel->draw(state);
 }