1
0
Fork 0

- add transparency option

- comment out date/time ... this needs to be added to the HUDs that need it
This commit is contained in:
mfranz 2006-06-09 20:37:16 +00:00
parent 942561d64c
commit 265e411791
2 changed files with 30 additions and 11 deletions

View file

@ -952,13 +952,17 @@ void drawHUD()
static char hud_wp2_text[256]; static char hud_wp2_text[256];
static char hud_alt_text[256]; static char hud_alt_text[256];
glEnable(GL_BLEND);
if (HUD->isTransparent())
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (HUD->isAntialiased()) { if (HUD->isAntialiased()) {
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glAlphaFunc(GL_GREATER, HUD->alphaClamp()); glAlphaFunc(GL_GREATER, HUD->alphaClamp());
// glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glLineWidth(2.0); glLineWidth(1.5);
} else { } else {
glLineWidth(1.0); glLineWidth(1.0);
} }
@ -966,7 +970,7 @@ void drawHUD()
HUD->setColor(); HUD->setColor();
for_each(HUD_deque.begin(), HUD_deque.end(), HUDdraw()); for_each(HUD_deque.begin(), HUD_deque.end(), HUDdraw());
HUD_TextList.add( fgText(40, 10, get_formated_gmt_time(), 0) ); //HUD_TextList.add( fgText(40, 10, get_formated_gmt_time(), 0) );
int apY = 480 - 80; int apY = 480 - 80;
@ -1022,7 +1026,6 @@ void drawHUD()
} }
HUD_TextList.draw(); HUD_TextList.draw();
HUD_LineList.draw(); HUD_LineList.draw();
// glEnable(GL_LINE_STIPPLE); // glEnable(GL_LINE_STIPPLE);
@ -1031,7 +1034,6 @@ void drawHUD()
// glDisable(GL_LINE_STIPPLE); // glDisable(GL_LINE_STIPPLE);
if (HUD->isAntialiased()) { if (HUD->isAntialiased()) {
// glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
glLineWidth(1.0); glLineWidth(1.0);
@ -1053,12 +1055,14 @@ void fgTextList::draw()
glPushAttrib(GL_COLOR_BUFFER_BIT); glPushAttrib(GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND); glEnable(GL_BLEND);
if (HUD->isTransparent())
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (HUD->isAntialiased()) { if (HUD->isAntialiased()) {
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, HUD->alphaClamp()); glAlphaFunc(GL_GREATER, HUD->alphaClamp());
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} else {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
} }
Font->begin(); Font->begin();
@ -1078,15 +1082,22 @@ HUD_Properties::HUD_Properties() :
_current(fgGetNode("/sim/hud/current-color", true)), _current(fgGetNode("/sim/hud/current-color", true)),
_visibility(fgGetNode("/sim/hud/visibility", true)), _visibility(fgGetNode("/sim/hud/visibility", true)),
_antialiasing(fgGetNode("/sim/hud/color/antialiased", true)), _antialiasing(fgGetNode("/sim/hud/color/antialiased", true)),
_transparency(fgGetNode("/sim/hud/color/transparent", true)),
_red(fgGetNode("/sim/hud/color/red", true)), _red(fgGetNode("/sim/hud/color/red", true)),
_green(fgGetNode("/sim/hud/color/green", true)), _green(fgGetNode("/sim/hud/color/green", true)),
_blue(fgGetNode("/sim/hud/color/blue", true)), _blue(fgGetNode("/sim/hud/color/blue", true)),
_alpha(fgGetNode("/sim/hud/color/alpha", true)), _alpha(fgGetNode("/sim/hud/color/alpha", true)),
_alpha_clamp(fgGetNode("/sim/hud/color/alpha-clamp", true)), _alpha_clamp(fgGetNode("/sim/hud/color/alpha-clamp", true)),
_brightness(fgGetNode("/sim/hud/color/brightness", true)) _brightness(fgGetNode("/sim/hud/color/brightness", true)),
_visible(false),
_antialiased(false),
_transparent(false),
_a(0.67),
_cl(0.01)
{ {
_visibility->addChangeListener(this); _visibility->addChangeListener(this);
_antialiasing->addChangeListener(this); _antialiasing->addChangeListener(this);
_transparency->addChangeListener(this);
_red->addChangeListener(this); _red->addChangeListener(this);
_green->addChangeListener(this); _green->addChangeListener(this);
_blue->addChangeListener(this); _blue->addChangeListener(this);
@ -1109,14 +1120,19 @@ void HUD_Properties::valueChanged(SGPropertyNode *node)
_green->setFloatValue(n->getFloatValue("green", 1.0)); _green->setFloatValue(n->getFloatValue("green", 1.0));
_blue->setFloatValue(n->getFloatValue("blue", 1.0)); _blue->setFloatValue(n->getFloatValue("blue", 1.0));
if (n->hasValue("alpha")) if (n->hasValue("alpha"))
_alpha->setFloatValue(n->getFloatValue("alpha", 1.0)); _alpha->setFloatValue(n->getFloatValue("alpha", 0.67));
if (n->hasValue("alpha-clamp")) if (n->hasValue("alpha-clamp"))
_alpha_clamp->setFloatValue(n->getFloatValue("alpha-clamp", 0.01)); _alpha_clamp->setFloatValue(n->getFloatValue("alpha-clamp", 0.01));
if (n->hasValue("brightness")) if (n->hasValue("brightness"))
_brightness->setFloatValue(n->getFloatValue("brightness", 0.75)); _brightness->setFloatValue(n->getFloatValue("brightness", 0.75));
if (n->hasValue("antialiased"))
_antialiasing->setBoolValue(n->getBoolValue("antialiased", false));
if (n->hasValue("transparent"))
_transparency->setBoolValue(n->getBoolValue("transparent", false));
} }
} }
_visible = _visibility->getBoolValue(); _visible = _visibility->getBoolValue();
_transparent = _transparency->getBoolValue();
_antialiased = _antialiasing->getBoolValue(); _antialiased = _antialiasing->getBoolValue();
float brt = _brightness->getFloatValue(); float brt = _brightness->getFloatValue();
_r = clamp(brt * _red->getFloatValue()); _r = clamp(brt * _red->getFloatValue());

View file

@ -1030,6 +1030,7 @@ public:
void setColor() const; void setColor() const;
bool isVisible() const { return _visible; } bool isVisible() const { return _visible; }
bool isAntialiased() const { return _antialiased; } bool isAntialiased() const { return _antialiased; }
bool isTransparent() const { return _transparent; }
float alphaClamp() const { return _cl; } float alphaClamp() const { return _cl; }
private: private:
@ -1037,11 +1038,13 @@ private:
SGPropertyNode_ptr _current; SGPropertyNode_ptr _current;
SGPropertyNode_ptr _visibility; SGPropertyNode_ptr _visibility;
SGPropertyNode_ptr _antialiasing; SGPropertyNode_ptr _antialiasing;
SGPropertyNode_ptr _transparency;
SGPropertyNode_ptr _red, _green, _blue, _alpha; SGPropertyNode_ptr _red, _green, _blue, _alpha;
SGPropertyNode_ptr _alpha_clamp; SGPropertyNode_ptr _alpha_clamp;
SGPropertyNode_ptr _brightness; SGPropertyNode_ptr _brightness;
bool _visible; bool _visible;
bool _antialiased; bool _antialiased;
bool _transparent;
float _r, _g, _b, _a, _cl; float _r, _g, _b, _a, _cl;
}; };