From bcb193f38b12f38993be747db4eed96df29376a9 Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 16 Feb 2006 18:59:48 +0000 Subject: [PATCH] Add support for emissive layers. --- src/Cockpit/panel.cxx | 21 ++++++++++++++++++--- src/Cockpit/panel.hxx | 3 +++ src/Cockpit/panel_io.cxx | 6 ++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index 35cff0df1..98d20c9fd 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -18,6 +18,15 @@ // // $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 +// tag by adding true tag. When omitted the default +// value is for backward compatibility set to false. + #ifdef HAVE_CONFIG_H # include #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); diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 9c110d072..183d4b4fe 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -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; }; diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index 32980d0e0..edfc072b0 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -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. -- 2.39.5