]> git.mxchange.org Git - flightgear.git/commitdiff
Add support for emissive layers.
authorehofman <ehofman>
Thu, 16 Feb 2006 18:59:48 +0000 (18:59 +0000)
committerehofman <ehofman>
Thu, 16 Feb 2006 18:59:48 +0000 (18:59 +0000)
src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Cockpit/panel_io.cxx

index 35cff0df1720416e91bcd4b922abb7e445c19372..98d20c9fdcd75637de745f8523c084a2de00ca40 100644 (file)
 //
 //  $Id$
 
+//JVK
+// On 2D panels all instruments include light sources were in night displayed
+// with a red mask (instrument light). It is not correct for light sources
+// (bulbs). There is added new layer property "emissive" (boolean) (only for
+// textured layers).
+// If a layer has to shine set it in the "instrument_def_file.xml" inside the
+// <layer> tag by adding <emissive>true</emissive> tag. When omitted the default
+// value is for backward compatibility set to false.
+
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
@@ -169,6 +178,7 @@ static fntRenderer text_renderer;
 static fntTexFont *default_font = 0;
 static fntTexFont *led_font = 0;
 static sgVec4 panel_color;
+static sgVec4 emissive_panel_color = {1,1,1,1};
 
 /**
  * Constructor.
@@ -955,7 +965,8 @@ FGGroupLayer::addLayer (FGInstrumentLayer * layer)
 
 
 FGTexturedLayer::FGTexturedLayer (const FGCroppedTexture &texture, int w, int h)
-  : FGInstrumentLayer(w, h)
+  : FGInstrumentLayer(w, h),
+    _emissive(false)
 {
   setTexture(texture);
 }
@@ -976,10 +987,14 @@ FGTexturedLayer::draw ()
     transform();
     glBindTexture(GL_TEXTURE_2D, _texture.getTexture()->getHandle());
     glBegin(GL_POLYGON);
-    
+
+    if (_emissive) {
+      glColor4fv( emissive_panel_color );
+    } else {
                                // From Curt: turn on the panel
                                // lights after sundown.
-    glColor4fv( panel_color );
+      glColor4fv( panel_color );
+    }
 
     glTexCoord2f(_texture.getMinX(), _texture.getMinY()); glVertex2f(-w2, -h2);
     glTexCoord2f(_texture.getMaxX(), _texture.getMinY()); glVertex2f(w2, -h2);
index 9c110d0722d7a8e898782f76aec23a840b7f7e2a..183d4b4fe476df0b239ca01058578a45c51c42fa 100644 (file)
@@ -493,8 +493,11 @@ public:
   virtual const FGCroppedTexture &getTexture () const { return _texture; }
   virtual FGCroppedTexture *getTexture() { return &_texture; }
 
+  void setEmissive(bool e) { _emissive = e; }
+
 private:
   FGCroppedTexture _texture;
+  bool _emissive;
 };
 
 
index 32980d0e0f817c85c63597e34be40d04cf5926f6..edfc072b0fabf6fe7993cdc97c4de7916f7cc141 100644 (file)
@@ -439,6 +439,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
   string type = node->getStringValue("type");
   int w = node->getIntValue("w", -1);
   int h = node->getIntValue("h", -1);
+  bool emissive = node->getBoolValue("emissive", false);
   if (w != -1)
     w = int(w * w_scale);
   if (h != -1)
@@ -457,6 +458,11 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
   if (type == "texture") {
     FGCroppedTexture texture = readTexture(node->getNode("texture"));
     layer = new FGTexturedLayer(texture, w, h);
+    if (emissive) {
+      FGTexturedLayer *tl=(FGTexturedLayer*)layer;
+      tl->setEmissive(true);
+    }
+
   }
 
                                // A group of sublayers.