#include <simgear/misc/sg_path.hxx>
#include <Aircraft/aircraft.hxx>
-#include <Autopilot/xmlauto.hxx>
+//#include <Autopilot/xmlauto.hxx>
#include <GUI/new_gui.hxx> // FGFontCache
#include <Main/globals.hxx>
-#include <Main/fg_props.hxx>
#include <Scenery/scenery.hxx>
#include "hud.hxx"
static char units[5];
-// The following routines obtain information concerning the aircraft's
-// current state and return it to calling instrument display routines.
-// They should eventually be member functions of the aircraft.
-//
-
-deque< instr_item * > HUD_deque;
+deque<instr_item *> HUD_deque;
-fgTextList HUD_TextList;
-fgLineList HUD_LineList;
-fgLineList HUD_StippleLineList;
+fgTextList HUD_TextList;
+fgLineList HUD_LineList;
+fgLineList HUD_StippleLineList;
fntRenderer *HUDtext = 0;
fntTexFont *HUD_Font = 0;
float HUD_matrix[16];
-static string name;
-static string label_format;
-static string prelabel;
-static string postlabel;
-static string type;
-static string type_pointer;
-static string type_tick;
-static string length_tick;
-
int readHud( istream &input );
int readInstrument ( const SGPropertyNode * node);
-static void drawHUD();
-static void fgUpdateHUDVirtual();
+static void drawHUD(osg::State*);
+static void fgUpdateHUDVirtual(osg::State*);
+
class locRECT {
public:
}
// #define DEBUG
-//========================= End of Class Implementations===================
-// fgHUDInit
-//
-// Constructs a HUD object and then adds in instruments. At the present
-// the instruments are hard coded into the routine. Ultimately these need
-// to be defined by the aircraft's instrumentation records so that the
-// display for a Piper Cub doesn't show the speed range of a North American
-// mustange and the engine readouts of a B36!
-//
int nCards = card_group->nChildren();
for (int j = 0; j < nCards; j++) {
const char *type = card_group->getChild(j)->getStringValue("type", "gauge");
+
if (!strcmp(type, "gauge"))
HIptr = static_cast<instr_item *>(new gauge_instr(card_group->getChild(j)));
else if (!strcmp(type, "dial") || !strcmp(type, "tape"))
HIptr = static_cast<instr_item *>(new hud_card(card_group->getChild(j)));
+ else {
+ SG_LOG(SG_INPUT, SG_WARN, "HUD: unknown 'card' type: " << type);
+ continue;
+ }
HUD_deque.insert(HUD_deque.begin(), HIptr);
}
}
}
+// fgHUDInit
+//
+// Constructs a HUD object and then adds in instruments. At the present
+// the instruments are hard coded into the routine. Ultimately these need
+// to be defined by the aircraft's instrumentation records so that the
+// display for a Piper Cub doesn't show the speed range of a North American
+// mustange and the engine readouts of a B36!
+//
int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
{
input.close();
}
- fgHUDReshape();
-
if ( HUDtext ) {
// this chunk of code is not necessarily thread safe if the
// compiler optimizer reorders these statements. Note that
}
+
int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
{
//$$$ End - added, Neetha, 28 Nov 2k
-void fgHUDReshape(void) {
-#if 0
- if ( HUDtext ) {
- // this chunk of code is not necessarily thread safe if the
- // compiler optimizer reorders these statements. Note that
- // "delete ptr" does not set "ptr = NULL". We have to do that
- // ourselves.
- fntRenderer *tmp = HUDtext;
- HUDtext = NULL;
- delete tmp;
- }
-
- HUD_TextSize = fgGetInt("/sim/startup/xsize") / 60;
- HUD_TextSize = 10;
- HUDtext = new fntRenderer();
- HUDtext -> setFont ( guiFntHandle ) ;
- HUDtext -> setPointSize ( HUD_TextSize ) ;
- HUD_TextList.setFont( HUDtext );
-#endif
-}
-
-
// fgUpdateHUD
//
// Performs a once around the list of calls to instruments installed in
// the HUD object with requests for redraw. Kinda. It will when this is
// all C++.
//
-void fgUpdateHUD( void ) {
+void fgUpdateHUD( osg::State* state ) {
static const SGPropertyNode *enable3d_node = fgGetNode("/sim/hud/enable3d");
if ( HUD_style == 1 && enable3d_node->getBoolValue() ) {
- fgUpdateHUDVirtual();
+ fgUpdateHUDVirtual(state);
return;
}
if ( current_aspect > normal_aspect ) {
float aspect_adjust = current_aspect / normal_aspect;
float adjust = 320.0f*aspect_adjust - 320.0f;
- fgUpdateHUD( -adjust, 0.0f, 640.0f+adjust, 480.0f );
+ fgUpdateHUD( state, -adjust, 0.0f, 640.0f+adjust, 480.0f );
} else {
float aspect_adjust = normal_aspect / current_aspect;
float adjust = 240.0f*aspect_adjust - 240.0f;
- fgUpdateHUD( 0.0f, -adjust, 640.0f, 480.0f+adjust );
+ fgUpdateHUD( state, 0.0f, -adjust, 640.0f, 480.0f+adjust );
}
}
-void fgUpdateHUDVirtual()
+void fgUpdateHUDVirtual(osg::State* state)
{
FGViewer* view = globals->get_current_view();
glTranslatef(-320, -240, -1);
// Do the deed
- drawHUD();
+ drawHUD(state);
// Clean up our mess
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
-void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
+
+void fgUpdateHUD( osg::State* state, GLfloat x_start, GLfloat y_start,
GLfloat x_end, GLfloat y_end )
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
- drawHUD();
+ drawHUD(state);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPopMatrix();
}
-void drawHUD()
+
+void drawHUD(osg::State* state)
{
if ( !HUD_deque.size() ) // Trust everyone, but ALWAYS cut the cards!
return;
//glLineWidth(1.0);
}
+ if (HUDprop->isTransparent())
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
}
-
void fgTextList::draw()
{
if (!Font)
Font->begin();
for (; curString != lastString; curString++)
- curString->Draw(Font,curString->digit);
+ curString->Draw(Font);
Font->end();
glDisable(GL_TEXTURE_2D);
}
-
// HUD property listener class
//
HUD_Properties::HUD_Properties() :
glColor3f(_r, _g, _b);
}
+