1
0
Fork 0

Add support for emissive layers.

This commit is contained in:
ehofman 2006-02-16 18:59:48 +00:00
parent 85707f1e49
commit bcb193f38b
3 changed files with 27 additions and 3 deletions

View file

@ -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
// <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);
}
@ -977,9 +988,13 @@ FGTexturedLayer::draw ()
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 );
}
glTexCoord2f(_texture.getMinX(), _texture.getMinY()); glVertex2f(-w2, -h2);
glTexCoord2f(_texture.getMaxX(), _texture.getMinY()); glVertex2f(w2, -h2);

View 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;
};

View 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.