]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/built_in/FGMagRibbon.cxx
Merge branch 'jmt/gps'
[flightgear.git] / src / Cockpit / built_in / FGMagRibbon.cxx
index f76d1126f758643f10dcc816696361116d6c3b51..a05db18ae50db9f671a41d3ea44f2fe08117cb74 100644 (file)
 //  WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 //  General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 //  $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
 #include "FGMagRibbon.hxx"
-#include "../steam.hxx"
 
 
 FGMagRibbon::FGMagRibbon (int w, int h)
@@ -28,12 +30,15 @@ FGMagRibbon::FGMagRibbon (int w, int h)
 {
   FGCroppedTexture texture("Aircraft/Instruments/Textures/compass-ribbon.rgb");
   setTexture(texture);
+  _magcompass_node =
+      fgGetNode("/instrumentation/magnetic-compass/indicated-heading-deg",
+                true);
 }
 
 void
-FGMagRibbon::draw ()
+FGMagRibbon::draw (osg::State& state)
 {
-  double heading = globals->get_steam()->get_MH_deg();
+  double heading = _magcompass_node->getDoubleValue();
   double xoffset, yoffset;
 
   while (heading >= 360.0) {
@@ -63,9 +68,19 @@ FGMagRibbon::draw ()
                                // Adjust to put the number in the centre
   xoffset -= 0.25;
 
-  FGCroppedTexture &t = getTexture();
-  t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
-  FGTexturedLayer::draw();
+  FGCroppedTexture *t = getTexture();
+  t->setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
+
+  static osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
+  stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
+
+  state.pushStateSet(stateSet.get());
+  state.apply();
+
+  FGTexturedLayer::draw(state);
+
+  state.popStateSet();
+  state.apply();
 }
 
 // end of FGMagRibbon.cxx