]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/wxradar.cxx
initialize variables before using them
[flightgear.git] / src / Instrumentation / wxradar.cxx
index 11aa71050b2842516fff817262f16d909153e24f..7319a5b418a4c6c29e26d9d0941a1be10b02f699 100644 (file)
 static const char *odgauge_name = "Aircraft/Instruments/Textures/od_wxradar.rgb";
 
 wxRadarBg::wxRadarBg ( SGPropertyNode *node) :
-    name("wxRadar"),
-    num(0),
+    _name(node->getStringValue("name", "wxRadar")),
+    _num(node->getIntValue("number", 0)),
     resultTexture( 0 ),
     wxEcho( 0 ),
     last_switchKnob( "off" ),
     sim_init_done ( false ),
     odg( 0 )
-{
-    int i;
-    for ( i = 0; i < node->nChildren(); ++i ) {
-        SGPropertyNode *child = node->getChild(i);
-        string cname = child->getName();
-        string cval = child->getStringValue();
-        if ( cname == "name" ) {
-            name = cval;
-        } else if ( cname == "number" ) {
-            num = child->getIntValue();
-        } else {
-            SG_LOG( SG_INSTR, SG_WARN, "Error in wxRadar config logic" );
-            if ( name.length() ) {
-                SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
-            }
-        }
-    }
-}
-
-wxRadarBg::wxRadarBg ()
 {
 }
 
@@ -79,15 +59,18 @@ void
 wxRadarBg::init ()
 {
     string branch;
-    branch = "/instrumentation/" + name;
+    branch = "/instrumentation/" + _name;
 
-    _Instrument = fgGetNode(branch.c_str(), num, true );
+    _Instrument = fgGetNode(branch.c_str(), _num, true );
     _serviceable_node = _Instrument->getChild("serviceable", 0, true);
     resultTexture = FGTextureManager::createTexture( odgauge_name );
     SGPath tpath(globals->get_fg_root());
     tpath.append("Aircraft/Instruments/Textures/wxecho.rgb");
     // no mipmap or else alpha will mix with pixels on the border of shapes, ruining the effect
-    wxEcho = new ssgTexture( tpath.c_str(), false, false, false);
+
+    // OSGFIXME
+//     wxEcho = new ssgTexture( tpath.c_str(), false, false, false);
+    wxEcho = new osg::Texture2D;
 
     _Instrument->setFloatValue("trk", 0.0);
     _Instrument->setFloatValue("tilt", 0.0);
@@ -110,6 +93,8 @@ wxRadarBg::init ()
 void
 wxRadarBg::update (double delta_time_sec)
 {
+  //OSGFIXME
+#if 0
     if ( ! sim_init_done ) {
         if ( ! fgGetBool("sim/sceneryloaded", false) )
             return;
@@ -130,7 +115,7 @@ wxRadarBg::update (double delta_time_sec)
         // we must locate them and replace their handle by hand
         // only do that when the instrument is turned on
         if ( last_switchKnob == "off" )
-            odg->set_texture( odgauge_name, resultTexture->getHandle());
+            odg->set_texture( odgauge_name, resultTexture.get());
         last_switchKnob = switchKnob;
     }
     FGViewer *current__view = globals->get_current_view();
@@ -189,7 +174,8 @@ wxRadarBg::update (double delta_time_sec)
         const float symbolSize = 1.0f / 8.0f ;
         // draw the radar echo, we do that in 3 passes, one for each color level
         // this is to 'merge' same colors together
-        glBindTexture(GL_TEXTURE_2D, wxEcho->getHandle() );
+        // OSGFIXME
+//         glBindTexture(GL_TEXTURE_2D, wxEcho->getHandle() );
         glColor3f(1.0f, 1.0f, 1.0f);
         glBegin( GL_QUADS );
 
@@ -335,5 +321,6 @@ wxRadarBg::update (double delta_time_sec)
         glEnable(GL_ALPHA_TEST);
     }
     glPopMatrix();
-    odg->endCapture( resultTexture->getHandle() );
+    odg->endCapture( resultTexture.get() );
+#endif
 }