From 265e411791d43424eb086bf3c392e51a0eb3f36e Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 9 Jun 2006 20:37:16 +0000 Subject: [PATCH] - add transparency option - comment out date/time ... this needs to be added to the HUDs that need it --- src/Cockpit/hud.cxx | 38 +++++++++++++++++++++++++++----------- src/Cockpit/hud.hxx | 3 +++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index 7195ad5c2..31210b252 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -952,13 +952,17 @@ void drawHUD() static char hud_wp2_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()) { glEnable(GL_LINE_SMOOTH); 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); - glLineWidth(2.0); + glLineWidth(1.5); } else { glLineWidth(1.0); } @@ -966,7 +970,7 @@ void drawHUD() HUD->setColor(); 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; @@ -1022,7 +1026,6 @@ void drawHUD() } HUD_TextList.draw(); - HUD_LineList.draw(); // glEnable(GL_LINE_STIPPLE); @@ -1031,7 +1034,6 @@ void drawHUD() // glDisable(GL_LINE_STIPPLE); if (HUD->isAntialiased()) { - // glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glDisable(GL_LINE_SMOOTH); glLineWidth(1.0); @@ -1053,12 +1055,14 @@ void fgTextList::draw() glPushAttrib(GL_COLOR_BUFFER_BIT); 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()) { glEnable(GL_ALPHA_TEST); 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(); @@ -1078,15 +1082,22 @@ HUD_Properties::HUD_Properties() : _current(fgGetNode("/sim/hud/current-color", true)), _visibility(fgGetNode("/sim/hud/visibility", true)), _antialiasing(fgGetNode("/sim/hud/color/antialiased", true)), + _transparency(fgGetNode("/sim/hud/color/transparent", true)), _red(fgGetNode("/sim/hud/color/red", true)), _green(fgGetNode("/sim/hud/color/green", true)), _blue(fgGetNode("/sim/hud/color/blue", true)), _alpha(fgGetNode("/sim/hud/color/alpha", 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); _antialiasing->addChangeListener(this); + _transparency->addChangeListener(this); _red->addChangeListener(this); _green->addChangeListener(this); _blue->addChangeListener(this); @@ -1109,14 +1120,19 @@ void HUD_Properties::valueChanged(SGPropertyNode *node) _green->setFloatValue(n->getFloatValue("green", 1.0)); _blue->setFloatValue(n->getFloatValue("blue", 1.0)); if (n->hasValue("alpha")) - _alpha->setFloatValue(n->getFloatValue("alpha", 1.0)); + _alpha->setFloatValue(n->getFloatValue("alpha", 0.67)); if (n->hasValue("alpha-clamp")) _alpha_clamp->setFloatValue(n->getFloatValue("alpha-clamp", 0.01)); if (n->hasValue("brightness")) _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(); + _transparent = _transparency->getBoolValue(); _antialiased = _antialiasing->getBoolValue(); float brt = _brightness->getFloatValue(); _r = clamp(brt * _red->getFloatValue()); diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx index 1a17ad631..763948d15 100644 --- a/src/Cockpit/hud.hxx +++ b/src/Cockpit/hud.hxx @@ -1030,6 +1030,7 @@ public: void setColor() const; bool isVisible() const { return _visible; } bool isAntialiased() const { return _antialiased; } + bool isTransparent() const { return _transparent; } float alphaClamp() const { return _cl; } private: @@ -1037,11 +1038,13 @@ private: SGPropertyNode_ptr _current; SGPropertyNode_ptr _visibility; SGPropertyNode_ptr _antialiasing; + SGPropertyNode_ptr _transparency; SGPropertyNode_ptr _red, _green, _blue, _alpha; SGPropertyNode_ptr _alpha_clamp; SGPropertyNode_ptr _brightness; bool _visible; bool _antialiased; + bool _transparent; float _r, _g, _b, _a, _cl; }; -- 2.39.5