hud.cxx hud.hxx \
hud_card.cxx hud_dnst.cxx hud_guag.cxx hud_inst.cxx \
hud_labl.cxx hud_ladr.cxx \
+ hud_lat.cxx hud_lon.cxx \
hud_scal.cxx hud_tbi.cxx \
panel.cxx panel.hxx
#include <Math/mat3.h>
#include <Math/polar3d.hxx>
#include <Scenery/scenery.hxx>
-#include <Time/fg_time.hxx>
#include <Time/fg_timer.hxx>
+#include <Time/fg_time.hxx>
#include "cockpit.hxx"
-#include "panel.hxx"
// This is a structure that contains all data related to
// The following routines obtain information concerntin the aircraft's
// current state and return it to calling instrument display routines.
// They should eventually be member functions of the aircraft.
+//
-double get_latitude( void )
+float get_latitude( void )
{
- return (double)((int)(current_aircraft.fdm_state->get_Latitude()*RAD_TO_DEG));
-}
+// FGState *f;
+ double lat;
+
+// current_aircraft.fdm_state
+
+ lat = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
+
+ float flat = lat;
+ return(flat);
-double get_lat_min( void )
+// if(fabs(lat)<1.0)
+// {
+// if(lat<0)
+// return( -(double)((int)lat) );
+// else
+// return( (double)((int)lat) );
+// }
+// return( (double)((int)lat) );
+}
+float get_lat_min( void )
{
- double a, d;
+// FGState *f;
+ double a, d;
- a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
+// current_aircraft.fdm_state
+
+ a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
if (a < 0.0) {
- a = -a;
+ a = -a;
}
d = (double) ( (int) a);
- return( (a - d) * 60.0);
+ float lat_min = (a - d) * 60.0;
+ return(lat_min );
}
-double get_longitude( void )
-{
- return( (double)((int) (current_aircraft.fdm_state->get_Longitude()
- * RAD_TO_DEG)) );
-}
-double get_long_min( void )
+float get_longitude( void )
{
- double a, d;
+ double lon;
+// FGState *f;
- a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
- if (a < 0.0) {
- a = -a;
- }
- d = (double) ( (int) a);
- return( (a - d) * 60.0);
+// current_aircraft.fdm_state
+
+ lon = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
+
+ float flon = lon;
+ return(flon);
+
+// if(fabs(lon)<1.0)
+// {
+// if(lon<0)
+// return( -(double)((int)lon) );
+// else
+// return( (double)((int)lon) );
+// }
+// return( (double)((int)lon) );
}
+
char*
get_formated_gmt_time( void )
{
FGTime *t = FGTime::cur_time_params;
const struct tm *p = t->getGmt();
sprintf( buf, "%d/%d/%2d %d:%02d:%02d",
- p->tm_mon+1, p->tm_mday, p->tm_year,
- p->tm_hour, p->tm_min, p->tm_sec);
+ p->tm_mon+1, p->tm_mday, p->tm_year,
+ p->tm_hour, p->tm_min, p->tm_sec);
return buf;
}
-double get_throttleval( void )
+float get_long_min( void )
+{
+// FGState *f;
+ double a, d;
+
+// current_aircraft.fdm_state
+
+ a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
+ if (a < 0.0) {
+ a = -a;
+ }
+ d = (double) ( (int) a);
+ float lon_min = (a - d) * 60.0;
+ return(lon_min);
+}
+
+float get_throttleval( void )
{
- return controls.get_throttle( 0 ); // Hack limiting to one engine
+ float throttle = controls.get_throttle( 0 );
+ return (throttle); // Hack limiting to one engine
}
-double get_aileronval( void )
+float get_aileronval( void )
{
- return controls.get_aileron();
+ float aileronval = controls.get_aileron();
+ return (aileronval);
}
-double get_elevatorval( void )
+float get_elevatorval( void )
{
- return controls.get_elevator();
+ float elevator_val = (float)controls.get_elevator();
+ return elevator_val;
}
-double get_elev_trimval( void )
+float get_elev_trimval( void )
{
- return controls.get_elevator_trim();
+ float elevatorval = controls.get_elevator_trim();
+ return (elevatorval);
}
-double get_rudderval( void )
+float get_rudderval( void )
{
- return controls.get_rudder();
+ float rudderval = controls.get_rudder();
+ return (rudderval);
}
-double get_speed( void )
+float get_speed( void )
{
- return( current_aircraft.fdm_state->get_V_equiv_kts() );
+ // Make an explicit function call.
+ float speed = current_aircraft.fdm_state->get_V_equiv_kts();
+ return( speed );
}
-double get_aoa( void )
+float get_aoa( void )
{
- return( current_aircraft.fdm_state->get_Alpha() * RAD_TO_DEG );
+ float aoa = current_aircraft.fdm_state->get_Alpha() * RAD_TO_DEG;
+ return( aoa );
}
-double get_roll( void )
+float get_roll( void )
{
- return( current_aircraft.fdm_state->get_Phi() );
+ float roll = current_aircraft.fdm_state->get_Phi();
+ return( roll );
}
-double get_pitch( void )
+float get_pitch( void )
{
- return( current_aircraft.fdm_state->get_Theta() );
+ float pitch = current_aircraft.fdm_state->get_Theta();
+ return( pitch );
}
-double get_heading( void )
+float get_heading( void )
{
- return( current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG );
+ float heading = (current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG);
+ return( heading );
}
-double get_altitude( void )
+float get_altitude( void )
{
+// FGState *f;
+ // double rough_elev;
+
+// current_aircraft.fdm_state
+ // rough_elev = mesh_altitude(f->get_Longitude() * RAD_TO_ARCSEC,
+ // f->get_Latitude() * RAD_TO_ARCSEC);
+ float altitude;
+
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
- return current_aircraft.fdm_state->get_Altitude();
+ altitude = current_aircraft.fdm_state->get_Altitude();
} else {
- return current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER;
+ altitude = (current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER);
}
+ return altitude;
}
-double get_agl( void )
+float get_agl( void )
{
+// FGState *f;
+
+// f = current_aircraft.fdm_state;
+
+ float agl;
+
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
- return current_aircraft.fdm_state->get_Altitude()
- - scenery.cur_elev * METER_TO_FEET;
+ agl = (current_aircraft.fdm_state->get_Altitude()
+ - scenery.cur_elev * METER_TO_FEET);
} else {
- return current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
- - scenery.cur_elev;
+ agl = (current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
+ - scenery.cur_elev);
}
+ return agl;
+}
+
+float get_sideslip( void )
+{
+// FGState *f;
+
+// f = current_aircraft.fdm_state;
+ float sideslip = current_aircraft.fdm_state->get_Beta();
+
+ return( sideslip );
}
-double get_sideslip( void )
+float get_frame_rate( void )
{
- return( current_aircraft.fdm_state->get_Beta() );
+ float frame_rate = general.get_frame_rate();
+ return (frame_rate);
}
-double get_frame_rate( void )
+float get_fov( void )
{
- return (double) general.get_frame_rate();
+ float fov = current_options.get_fov();
+ return (fov);
}
-double get_fov( void )
+float get_vfc_ratio( void )
{
- return (current_options.get_fov());
+ float vfc = current_view.get_vfc_ratio();
+ return (vfc);
}
-double get_vfc_ratio( void )
+float get_vfc_tris_drawn ( void )
{
- return current_view.get_vfc_ratio();
+ float rendered = current_view.get_tris_rendered();
+ return (rendered);
}
-double get_vfc_tris_drawn ( void )
+float get_vfc_tris_culled ( void )
{
- return current_view.get_tris_rendered();
+ float culled = current_view.get_tris_culled();
+ return (culled);
}
-double get_climb_rate( void )
+float get_climb_rate( void )
{
+// FGState *f;
+
+// current_aircraft.fdm_state
+
+ float climb_rate;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
- return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
+ climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
} else {
- return current_aircraft.fdm_state->get_Climb_Rate()
- * FEET_TO_METER * 60.0;
+ climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * FEET_TO_METER * 60.0;
}
+ return (climb_rate);
}
+float get_view_direction( void )
+{
+// FGState *f;
+
+
+// FGView *pview;
+ double view;
+
+// pview = ¤t_view;
+// current_aircraft.fdm_state
+
+ view = FG_2PI - current_view.get_view_offset();
+
+ view = ( current_aircraft.fdm_state->get_Psi() + view) * RAD_TO_DEG;
+ if(view > 360.)
+ view -= 360.;
+ else if(view<0.)
+ view += 360.;
+ float fview = view;
+ return( fview );
+}
+
+#ifdef NOT_USED
+/****************************************************************************/
+/* Convert degrees to dd mm'ss.s" (DMS-Format) */
+/****************************************************************************/
+char *dmshh_format(double degrees)
+{
+ static char buf[16];
+ int deg_part;
+ int min_part;
+ double sec_part;
+
+ if (degrees < 0)
+ degrees = -degrees;
+
+ deg_part = degrees;
+ min_part = 60.0 * (degrees - deg_part);
+ sec_part = 3600.0 * (degrees - deg_part - min_part / 60.0);
+
+ /* Round off hundredths */
+ if (sec_part + 0.005 >= 60.0)
+ sec_part -= 60.0, min_part += 1;
+ if (min_part >= 60)
+ min_part -= 60, deg_part += 1;
+
+ sprintf(buf,"%02d*%02d\'%05.2f\"",deg_part,min_part,sec_part);
+
+ return buf;
+}
+#endif // 0
+
+/****************************************************************************/
+/* Convert degrees to dd mm'ss.s'' (DMS-Format) */
+/****************************************************************************/
+static char *toDMS(float a)
+{
+ int neg = 0;
+ float d, m, s;
+ static char dms[16];
+
+ if (a < 0.0f) {
+ a = -a;
+ neg = 1;
+ }
+ d = (float) ((int) a);
+ a = (a - d) * 60.0f;
+ m = (float) ((int) a);
+ s = (a - m) * 60.0f;
+
+ if (s > 59.5f) {
+ s = 0.0f;
+ m += 1.0f;
+ }
+ if (m > 59.5f) {
+ m = 0.0f;
+ d += 1.0f;
+ }
+ if (neg)
+ d = -d;
+
+ sprintf(dms, "%.0f*%02.0f'%04.1f\"", d, m, s);
+ return dms;
+}
+
+
+/****************************************************************************/
+/* Convert degrees to dd mm.mmm' (DMM-Format) */
+/****************************************************************************/
+static char *toDM(float a)
+{
+ int neg = 0;
+ float d, m;
+ static char dm[16];
+
+ if (a < 0.0f) {
+ a = -a;
+ neg = 1;
+ }
+
+ d = (float) ( (int) a);
+ m = (a - d) * 60.0f;
+
+ if (m > 59.5f) {
+ m = 0.0f;
+ d += 1.0f;
+ }
+ if (neg) d = -d;
+
+ sprintf(dm, "%.0f*%06.3f'", d, m);
+ return dm;
+}
+
+static char *(*fgLatLonFormat)(float);
+
+char *coord_format_lat(float latitude)
+{
+ static char buf[16];
+
+ sprintf(buf,"%s%c",
+// dmshh_format(latitude),
+// toDMS(latitude),
+// toDM(latitude),
+ fgLatLonFormat(latitude),
+ latitude > 0 ? 'N' : 'S');
+ return buf;
+}
+
+char *coord_format_lon(float longitude)
+{
+ static char buf[80];
+
+ sprintf(buf,"%s%c",
+// dmshh_format(longitude),
+// toDMS(longitude),
+// toDM(longitude),
+ fgLatLonFormat(longitude),
+ longitude > 0 ? 'E' : 'W');
+ return buf;
+}
+
+void fgLatLonFormatToggle( puObject *)
+{
+ static int toggle = 0;
+
+ if ( toggle )
+ fgLatLonFormat = toDM;
+ else
+ fgLatLonFormat = toDMS;
+
+ toggle = ~toggle;
+}
+
+#ifdef NOT_USED
+char *coord_format_latlon(double latitude, double longitude)
+{
+ static char buf[1024];
+
+ sprintf(buf,"%s%c %s%c",
+ dmshh_format(latitude),
+ latitude > 0 ? 'N' : 'S',
+ dmshh_format(longitude),
+ longitude > 0 ? 'E' : 'W');
+ return buf;
+}
+#endif
+
+#ifdef FAST_TEXT_TEST
+#undef FAST_TEXT_TEST
+#endif
+
+#ifdef FAST_TEXT_TEST
+
+static unsigned int first=0, last=128;
+unsigned int font_base;
+
+#define FONT "-adobe-courier-medium-r-normal--24-240-75-75-m-150-iso8859-1"
+HFONT hFont;
+
+void Font_Setup(void)
+{
+#ifdef _WIN32
+ int count;
+ HDC hdc;
+ HGLRC hglrc;
+
+
+ hdc = wglGetCurrentDC();
+ hglrc = wglGetCurrentContext();
+
+ if (hdc == 0 || hglrc == 0) {
+ printf("Could not get context or DC\n");
+ exit(1);
+ }
+
+ if (!wglMakeCurrent(hdc, hglrc)) {
+ printf("Could not make context current\n");
+ exit(1);
+ }
+
+#define FONTBASE 0x1000
+ /*
+ hFont = GetStockObject(SYSTEM_FONT);
+ hFont = CreateFont(h, w, esc, orient, weight,
+ ital, under, strike, set, out, clip, qual, pitch/fam, face);
+ */
+ hFont = CreateFont(30, 0, 0, 0, FW_NORMAL,
+ FALSE, FALSE, FALSE, ANSI_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY,
+ FIXED_PITCH | FF_MODERN, "Arial");
+ if (!hFont) {
+ MessageBox(WindowFromDC(hdc),
+ "Failed to find acceptable bitmap font.",
+ "OpenGL Application Error",
+ MB_ICONERROR | MB_OK);
+ exit(1);
+ }
+ (void) SelectObject(hdc, hFont);
+ wglUseFontBitmaps(hdc, 0, 255, FONTBASE);
+ glListBase(FONTBASE);
+#if 0
+ SelectObject (hdc, GetStockObject (SYSTEM_FONT));
+
+ count=last-first+1;
+ font_base = glGenLists(count);
+ wglUseFontBitmaps (hdc, first, last, font_base);
+ if (font_base == 0) {
+ printf("Could not generate Text_Setup list\n");
+ exit(1);
+ }
+#endif // 0
+#else
+ Display *Dpy;
+ XFontStruct *fontInfo;
+ Font id;
+
+ Dpy = XOpenDisplay(NULL);
+ fontInfo = XLoadQueryFont(Dpy, FONT);
+ if (fontInfo == NULL)
+ {
+ printf("Failed to load font %s\n", FONT);
+ exit(1);
+ }
+
+ id = fontInfo->fid;
+ first = fontInfo->min_char_or_byte2;
+ last = fontInfo->max_char_or_byte2;
+
+ base = glGenLists((GLuint) last+1);
+ if (base == 0) {
+ printf ("out of display lists\n");
+ exit (1);
+ }
+ glXUseXFont(id, first, last-first+1, base+first);
+#endif
+}
+
+static void
+drawString(char *string, GLfloat x, GLfloat y, GLfloat color[4])
+{
+ glColor4fv(color);
+ glRasterPos2f(x, y);
+ glCallLists(strlen(string), GL_BYTE, (GLbyte *) string);
+}
+
+#endif // #ifdef FAST_TEXT_TEST
+
bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
{
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing cockpit subsystem" );
- // cockpit->code = 1; /* It will be aircraft dependent */
- // cockpit->status = 0;
+ // cockpit->code = 1; /* It will be aircraft dependent */
+ // cockpit->status = 0;
// If aircraft has HUD specified we will get the specs from its def
// file. For now we will depend upon hard coding in hud?
// HI_Head is now a null pointer so we can generate a new list from the
// current aircraft.
+#ifdef FAST_TEXT_TEST
+ Font_Setup();
+#endif // #ifdef FAST_TEXT_TEST
+
fgHUDInit( cur_aircraft );
ac_cockpit = new fg_Cockpit();
new FGPanel;
}
+ // Have to set the LatLon display type
+ fgLatLonFormat = toDM;
+
FG_LOG( FG_COCKPIT, FG_INFO,
- " Code " << ac_cockpit->code() << " Status "
- << ac_cockpit->status() );
+ " Code " << ac_cockpit->code() << " Status "
+ << ac_cockpit->status() );
return true;
}
void fgCockpitUpdate( void ) {
+
+#define DISPLAY_COUNTER
+#ifdef DISPLAY_COUNTER
+ static float lightCheck[4] = { 0.7F, 0.7F, 0.7F, 1.0F };
+ char buf[64],*ptr;
+// int fontSize;
+ int c;
+#endif
+
FG_LOG( FG_COCKPIT, FG_DEBUG,
- "Cockpit: code " << ac_cockpit->code() << " status "
- << ac_cockpit->status() );
+ "Cockpit: code " << ac_cockpit->code() << " status "
+ << ac_cockpit->status() );
if ( current_options.get_hud_status() ) {
- // This will check the global hud linked list pointer.
- // If these is anything to draw it will.
- fgUpdateHUD();
+ // This will check the global hud linked list pointer.
+ // If these is anything to draw it will.
+ fgUpdateHUD();
+ }
+#ifdef DISPLAY_COUNTER
+ else
+ {
+ float fps = get_frame_rate();
+ float tris = fps * get_vfc_tris_drawn();
+ float culled = fps * get_vfc_tris_culled();
+
+ int len = sprintf(buf," %4.1f %7.0f %7.0f",
+ fps, tris, culled);
+// sprintf(buf,"Tris Per Sec: %7.0f", t);
+// fontSize = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+
+ glLoadIdentity();
+ gluOrtho2D(0, 1024, 0, 768);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_LIGHTING);
+
+// glColor3f (.90, 0.27, 0.67);
+
+
+#ifdef FAST_TEXT_TEST
+ drawString(buf, 250.0F, 10.0F, lightCheck);
+// glRasterPos2f( 220, 10);
+// for (int i=0; i < len; i++) {
+// glCallList(font_base+buf[i]);
+// }
+#else
+ glColor3f (.8, 0.8, 0.8);
+ glTranslatef( 400, 10, 0);
+ glScalef(.1, .1, 0.0);
+ ptr = buf;
+ while ( ( c = *ptr++) ){
+ glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
+ }
+#endif // #ifdef FAST_TEXT_TEST
+
+// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, ' ');
+// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, ' ');
+
+// ptr = get_formated_gmt_time();
+// while ( ( c = *ptr++) ){
+// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
+// }
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
}
+#endif // DISPLAY_COUNTER
if ( current_options.get_panel_status() &&
- (fabs( current_view.get_view_offset() ) < 0.2) )
+ (fabs( current_view.get_view_offset() ) < 0.2) )
{
- xglViewport( 0, 0,
- current_view.get_winWidth(),
- current_view.get_winHeight() );
- FGPanel::OurPanel->Update();
+ xglViewport( 0, 0,
+ current_view.get_winWidth(),
+ current_view.get_winHeight() );
+ FGPanel::OurPanel->Update();
}
}
-
-
-// cockpit.hxx -- cockpit defines and prototypes (initial draft)
-//
-// Written by Michele America, started September 1997.
-//
-// Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
+/**************************************************************************
+ * cockpit.hxx -- cockpit defines and prototypes (initial draft)
+ *
+ * Written by Michele America, started September 1997.
+ *
+ * Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ **************************************************************************/
#ifndef _COCKPIT_HXX
#include "panel.hxx"
// Class fg_Cockpit This class is a holder for the heads up display
-// and is initialized with a
+// and is initialized with a
class fg_Cockpit {
private:
int Code;
void fgCockpitUpdate( void );
-#endif // _COCKPIT_HXX
-
-
+#endif /* _COCKPIT_HXX */
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_VALUES_H
+# include <values.h> // for MAXINT
+#endif
+
#include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx>
+#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Main/options.hxx>
#include <Math/fg_random.h>
#include "hud.hxx"
-
static char units[5];
-// The following routines obtain information concerntin the aircraft's
+// 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.
//
-HudContainerType HUD_deque;
+deque< instr_item * > HUD_deque;
+vector< fgLineSeg2D > HUD_LineList;
+vector< fgLineSeg2D > HUD_StippleLineList;
+
+#ifdef USE_HUD_TextList
+vector< fgTextString > HUD_TextList;
+#endif
+
+//GLFONT *myFont;
class locRECT {
public:
/* textString - Bitmap font string */
void textString( int x, int y, char *msg, void *font ){
- glRasterPos2f(x, y);
- while (*msg) {
- glutBitmapCharacter(font, *msg);
- msg++;
+
+ if(*msg)
+ {
+// puDrawString ( NULL, msg, x, y );
+
+ glRasterPos2f(x, y);
+ while (*msg) {
+ glutBitmapCharacter(font, *msg);
+ msg++;
+ }
}
}
-/* strokeString - Stroke font string */
+/* strokeString - Stroke font string */
void strokeString(int x, int y, char *msg, void *font, float theta)
{
-int xx;
-int yy;
-
- glPushMatrix();
- glRotatef(theta * RAD_TO_DEG, 0.0, 0.0, 1.0);
- xx = (int)(x * cos(theta) + y * sin( theta ));
- yy = (int)(y * cos(theta) - x * sin( theta ));
- glTranslatef( xx, yy, 0);
- glScalef(.1, .1, 0.0);
- while (*msg) {
- glutStrokeCharacter(font, *msg);
- msg++;
- }
- glPopMatrix();
+ int xx;
+ int yy;
+ int c;
+ float sintheta,costheta;
+
+
+ if(*msg)
+ {
+ glPushMatrix();
+ glRotatef(theta * RAD_TO_DEG, 0.0, 0.0, 1.0);
+ sintheta = sin(theta);
+ costheta = cos(theta);
+ xx = (int)(x * costheta + y * sintheta);
+ yy = (int)(y * costheta - x * sintheta);
+ glTranslatef( xx, yy, 0);
+ glScalef(.1, .1, 0.0);
+ while( (c=*msg++) ) {
+ glutStrokeCharacter(font, c);
+ }
+ glPopMatrix();
+ }
}
//========================= End of Class Implementations===================
int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
{
instr_item *HIptr;
- int index;
+// int index;
+ int font_size;
+
+ int off = 50;
+ int min_x = 25; //off/2;
+ int max_x = 615; //640-(off/2);
+// int min_y = off;
+ int max_y = 430; //480-off;
+ int cen_x = 320;
+ int cen_y = 240;
+ unsigned int text_h = 10;
+ unsigned int ladr_w2 = 60;
+ int ladr_h2 = 90;
+ int ladr_t = 35;
+// int compass_w2 = 100;
+ int gap = 10;
+
+ font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
+// deque < instr_item * > :: iterator first = HUD_deque.begin();
+// deque < instr_item * > :: iterator last = HUD_deque.end();
+// HUD_deque.erase( first, last); // empty the HUD deque
+
HUD_deque.erase( HUD_deque.begin(), HUD_deque.end()); // empty the HUD deque
// hud->code = 1;
// fgHUDSetTimeMode( hud, NIGHT );
// fgHUDSetBrightness( hud, BRT_LIGHT );
- index = 0;
-
- do {
- switch ( index ) {
- case 0: // TBI
- HIptr = (instr_item *) new fgTBI_instr( 270, 100, 60, 10 );
- break;
-
- case 1: // Artificial Horizon
- HIptr = (instr_item *) new HudLadder( 240, 195, 120, 180 );
- break;
-
- case 2: // KIAS
- HIptr = (instr_item *) new hud_card( 130,
- 170,
- 28,
- 200,
- get_speed,
- HUDS_LEFT | HUDS_VERT,
- 200.0, 0.0,
- 1.0,
- 10, 5,
- 0,
- 0,
- 50.0,
- true);
-
- break;
-
- case 3: // Radio Altimeter
- HIptr = (instr_item *) new hud_card( 420,
- 195,
- 25,
- 150,
- get_agl,
- HUDS_LEFT | HUDS_VERT,
- 1000, 0,
- 1.0,
- 25, 5,
- 0,
- 0,
- 200.0,
- true);
- break;
-
- case 4: // GYRO COMPASS
- HIptr = (instr_item *) new hud_card( 200,
- 375,
- 200,
- 28,
- get_heading,
- HUDS_TOP,
- 360, 0,
- 1.0,
- 5, 1,
- 360,
- 0,
- 25,
- true);
- break;
-
- case 5: // AMSL
- HIptr = (instr_item *) new hud_card( 460,
- 170,
- 35,
- 200,
- get_altitude,
- HUDS_RIGHT | HUDS_VERT,
- 15000, -500,
- 1.0,
- 100, 25,
- 0,
- 0,
- 250,
- true);
- break;
-
- case 6:
- HIptr = (instr_item *) new guage_instr( 250, // x
- 350, // y
- 100, // width
- 20, // height
- get_aileronval, // data source
- HUDS_BOTTOM | HUDS_NOTEXT,
- 100.0,
- +1.0,
- -1.0);
- break;
-
- case 7:
- HIptr = (instr_item *) new guage_instr( 170, // x
- 225, // y
- 20, // width
- 100, // height
- get_elevatorval, // data source
- HUDS_RIGHT | HUDS_VERT | HUDS_NOTEXT,
- -100.0, // Scale data
- +1.0, // Data Range
- -1.0);
- break;
-
- case 8:
- HIptr = (instr_item *) new guage_instr( 250, // x
- 200, // y
- 100, // width
- 20, // height
- get_rudderval, // data source
- HUDS_TOP | HUDS_NOTEXT,
- 100.0,
- +1.0,
- -1.0);
- break;
-
- case 9:
- HIptr = (instr_item *) new guage_instr( 100, // x
- 190,
- 20,
- 160, // height
- get_throttleval, // data source
- HUDS_VERT | HUDS_RIGHT | HUDS_NOTEXT,
- 100.0,
- 1.0,
- 0.0);
- break;
-
- case 10: // Digital KIAS
+// case 0: // TBI
+ int x = 290; /*cen_x-30*/
+ int y = 45; /*off-5*/
+// HIptr = (instr_item *) new fgTBI_instr( x, y, ladr_w2, text_h );
+ HIptr = (instr_item *) new fgTBI_instr( 290, 45, 60, 10 );
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 1: // Artificial Horizon
+ HIptr = (instr_item *) new HudLadder( cen_x-ladr_w2, cen_y-ladr_h2,
+ 2*ladr_w2, 2*ladr_h2 );
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 4: // GYRO COMPASS
+ HIptr = (instr_item *) new hud_card( cen_x-100,
+ max_y,
+ 200,
+ 28,
+ get_heading,
+ HUDS_TOP,
+ 360, 0,
+ 1.0,
+ 5, 1,
+ 360,
+ 0,
+ 25,
+ true);
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 5: // AMSL
+ HIptr = (instr_item *) new hud_card( max_x - 35 -15, // 15 to balance speed card
+ cen_y-100,
+ 35,
+ 200,
+ get_altitude,
+// HUDS_RIGHT | HUDS_VERT,
+ HUDS_LEFT | HUDS_VERT,
+ 5000, -1000,
+ 1.0,
+ 100, 25,
+ 0,
+ 0,
+ 250,
+ true);
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 6:
+ HIptr = (instr_item *) new guage_instr( cen_x-50, // x
+ cen_y + ladr_h2 -20, // y
+ 100, // width
+ 20, // height
+ get_aileronval, // data source
+ HUDS_BOTTOM | HUDS_NOTEXT,
+ 100.0,
+ +1.0,
+ -1.0);
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 3: // Radio Altimeter
+ HIptr = (instr_item *) new hud_card( cen_x + ladr_w2 + gap + 13 + ladr_t,
+ cen_y-75,
+ 25,
+ 150,
+ get_agl,
+ HUDS_LEFT | HUDS_VERT,
+ 1000, 0,
+ 1.0,
+ 25, 5,
+ 0,
+ 0,
+ 200.0,
+ true);
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 7:
+ HIptr = (instr_item *) new guage_instr( cen_x -ladr_w2 -gap -13 -20 -ladr_t,
+ cen_y-50, // y
+ 20, // width
+ 100, // height
+ get_elevatorval, // data source
+ HUDS_RIGHT | HUDS_VERT | HUDS_NOTEXT,
+ -100.0, // Scale data
+ +1.0, // Data Range
+ -1.0);
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 8:
+ HIptr = (instr_item *) new guage_instr( cen_x-50, // x
+ cen_y -gap -ladr_w2 -20, //-85 // y
+ 100, // width
+ 20, // height
+ get_rudderval, // data source
+ HUDS_TOP | HUDS_NOTEXT,
+ 100.0,
+ +1.0,
+ -1.0);
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 2: // KIAS
+ HIptr = (instr_item *) new hud_card( min_x +10 +5, //min_x +18,
+ cen_y-100,
+ 28,
+ 200,
+ get_speed,
+// HUDS_LEFT | HUDS_VERT,
+ HUDS_RIGHT | HUDS_VERT,
+ 200.0, 0.0,
+ 1.0,
+ 10, 5,
+ 0,
+ 0,
+ 50.0,
+ true);
+
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 9:
+ HIptr = (instr_item *) new guage_instr( min_x-10, // x
+ cen_y -75, // y
+ 20, // width
+ 150, // height
+ get_throttleval, // data source
+// HUDS_VERT | HUDS_RIGHT | HUDS_NOTEXT,
+ HUDS_VERT | HUDS_LEFT | HUDS_NOTEXT, 100.0,
+ 1.0,
+ 0.0
+ );
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+// Remove this when below uncommented
+// case 10:
+ HIptr = (instr_item *) new instr_label( 10,
+ 10,
+ 60,
+ 10,
+ get_frame_rate,
+ "%5.1f",
+ "",
+ NULL,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+ HIptr = (instr_item *) new lat_label( (cen_x -ladr_w2)/2,
+ max_y,
+ 60,
+ text_h,
+ get_latitude,
+ "%s%", //"%.0f",
+ "", //"Lat ",
+ "",
+ 1.0,
+ HUDS_TOP,
+ CENTER_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+ HIptr = (instr_item *) new lon_label(
+ //(cen_x+ladr_x2) +((max_x-(cen_x+ladr_x2))/2),
+ (2*cen_x) - ((cen_x -ladr_w2)/2),
+ max_y,
+ 60, text_h,
+ get_longitude,
+ "%s%",//"%.0f",
+ "", //"Lon ",
+ "",
+ 1.0,
+ HUDS_TOP,
+ CENTER_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+/*
+// case 10: // Digital KIAS
HIptr = (instr_item *) new instr_label ( 110,
150,
40,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 11: // Digital Rate of Climb
+// case 11: // Digital Rate of Climb
HIptr = (instr_item *) new instr_label ( 110,
135,
40,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 12: // Roll indication diagnostic
+// case 12: // Roll indication diagnostic
HIptr = (instr_item *) new instr_label ( 110,
120,
40,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 13: // Angle of attack diagnostic
+// case 13: // Angle of attack diagnostic
HIptr = (instr_item *) new instr_label ( 440,
150,
60,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 14:
+// case 14:
HIptr = (instr_item *) new instr_label ( 440,
135,
60,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 15:
+// case 15:
HIptr = (instr_item *) new instr_label ( 440,
120,
60,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 16:
+// case 16:
HIptr = (instr_item *) new instr_label( 440,
100,
60,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 17:
+// case 17:
HIptr = (instr_item *) new instr_label( 440,
85,
60,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 18:
+// case 18:
HIptr = (instr_item *) new instr_label( 440,
60,
60,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
-
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
- case 19:
+// case 19:
HIptr = (instr_item *) new instr_label( 10,
10,
60,
10,
get_frame_rate,
- "%.0f",
+ "%.1f",
"Frame rate = ",
NULL,
1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
-
- case 20:
- switch( current_options.get_tris_or_culled() ) {
- case 0:
- HIptr = (instr_item *) new instr_label( 10,
- 25,
- 90,
- 10,
- get_vfc_tris_drawn,
- "%.0f",
- "Tris Rendered = ",
- NULL,
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
- break;
- case 1:
- HIptr = (instr_item *) new instr_label( 10,
- 25,
- 90,
- 10,
- get_vfc_ratio,
- "%.2f",
- "VFC Ratio = ",
- NULL,
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
- break;
- }
- break;
-
- case 21:
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// case 20:
+ switch( current_options.get_tris_or_culled() ) {
+ case 0:
+ HIptr = (instr_item *) new instr_label( 10,
+ 25,
+ 120,
+ 10,
+ get_vfc_tris_drawn,
+ "%.0f",
+ "Tris Rendered = ",
+ NULL,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
+ break;
+ case 1:
+ HIptr = (instr_item *) new instr_label( 10,
+ 25,
+ 90,
+ 10,
+ get_vfc_ratio,
+ "%.2f",
+ "VFC Ratio = ",
+ NULL,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
+ break;
+ }
+ break;
+
+// case 21:
HIptr = (instr_item *) new instr_label( 10,
40,
90,
"%.1f",
"FOV = ",
NULL,
- 1.0,
+ 1.0,
HUDS_TOP,
RIGHT_JUST,
- SMALL,
+ font_size,
0,
TRUE );
- break;
-
- default:
- HIptr = 0;;
- }
- if( HIptr ) { // Anything to install?
- HUD_deque.insert( HUD_deque.begin(), HIptr);
- }
- index++;
- }
- while( HIptr );
+ HUD_deque.insert( HUD_deque.begin(), HIptr);
+*/
+// default:
+// HIptr = 0;;
+// }
+// if( HIptr ) { // Anything to install?
+// HUD_deque.insert( HUD_deque.begin(), HIptr);
+// }
+// index++;
+// }
+// while( HIptr );
return 0; // For now. Later we may use this for an error code.
+
}
int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
{
- int index;
+// instr_item *HIptr;
+// int index;
+ int font_size;
+
+ int off = 50;
+// int min_x = off;
+// int max_x = 640-off;
+// int min_y = off;
+ int max_y = 480-off;
+ int cen_x = 640 / 2;
+// int cen_y = 480 / 2;
+ int text_h = 10;
+ int ladr_w2 = 60;
+// int ladr_h2 = 90;
+// int ladr_t = 35;
+// int compass_w2 = 100;
+// int gap = 10;
+
+ font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
+// deque < instr_item * > :: iterator first = HUD_deque.begin();
+// deque < instr_item * > :: iterator last = HUD_deque.end();
+// HUD_deque.erase( first, last); // empty the HUD deque
HUD_deque.erase( HUD_deque.begin(), HUD_deque.end());
// hud->code = 1;
// fgHUDSetBrightness( hud, BRT_LIGHT );
// index = 0;
- index = 19;
+// index = 19;
instr_item* p;
+// case 4: // GYRO COMPASS
+ p =new hud_card( cen_x-100,
+ max_y,
+ 200,
+ 28,
+ get_view_direction,
+ HUDS_TOP,
+ 360, 0,
+ 1.0,
+ 5, 1,
+ 360,
+ 0,
+ 25,
+ true);
+ HUD_deque.push_front( p );
+
+ p = new lat_label( (cen_x -ladr_w2)/2,
+ max_y,
+ 60, text_h,
+ get_latitude,
+ "%s%", //"%.0f",
+ "", //"Lat ",
+ "",
+ 1.0,
+ HUDS_TOP,
+ CENTER_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.push_front( p );
+
+// p = new instr_label( 140, 450, 60, 10,
+// get_lat_min,
+// "%05.2f",
+// "",
+// NULL,
+// 1.0,
+// HUDS_TOP,
+// CENTER_JUST,
+// font_size,
+// 0,
+// TRUE );
+// HUD_deque.push_front( p );
+
+ p = new lon_label( (2*cen_x) - ((cen_x -ladr_w2)/2),
+ max_y,
+ 60, text_h,
+ get_longitude,
+ "%s%",//"%.0f",
+ "", //"Lon ",
+ "",
+ 1.0,
+ HUDS_TOP,
+ CENTER_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.push_front( p );
+
+// p = new instr_label( 480, 450, 60, 10,
+// get_long_min,
+// "%05.2f",
+// "",
+// NULL,
+// 1.0,
+// HUDS_TOP,
+// CENTER_JUST,
+// font_size,
+// 0,
+// TRUE );
+// HUD_deque.push_front( p );
+
p = new instr_label( 10, 10, 60, 10,
- get_frame_rate,
- "%.0f",
- "Frame rate = ",
- NULL,
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
+ get_frame_rate,
+ "%7.1f",
+ "Frame rate =",
+ NULL,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
HUD_deque.push_front( p );
- if ( current_options.get_tris_or_culled() == 0 )
- p = new instr_label( 10, 25, 90, 10,
- get_vfc_tris_drawn,
- "%.0f",
- "Tris Rendered = ",
- NULL,
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
- else
- p = new instr_label( 10, 25, 90, 10,
- get_vfc_ratio,
- "%.2f",
- "VFC Ratio = ",
- NULL,
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
+ p = new instr_label( 10, 25, 120, 10,
+ get_vfc_tris_culled,
+ "%7.0f",
+ "Culled =",
+ NULL,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
HUD_deque.push_front( p );
- p = new instr_label( 10, 40, 90, 10,
- get_fov,
- "%.1f",
- "FOV = ",
- NULL,
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
+ p = new instr_label( 10, 40, 120, 10,
+ get_vfc_tris_drawn,
+ "%7.0f",
+ "Rendered =",
+ NULL,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.push_front( p );
+
+ p = new instr_label( 10, 55, 90, 10,
+ get_fov,
+ "%7.1f",
+ "FOV ",
+ NULL,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
HUD_deque.push_front( p );
const int x_pos = 480;
- p = new instr_label( x_pos, 40, 40, 30,
- get_speed,
- "%5.0f",
- "Airspeed ",
- " Kts",
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
+
+ p = new instr_label ( x_pos,
+ 70,
+ 60,
+ 10,
+ get_aoa,
+ "%7.2f",
+ "AOA ",
+ " Deg",
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.push_front( p );
+
+ p = new instr_label( x_pos, 55, 40, 30,
+ get_speed,
+ "%5.0f",
+ "Airspeed ",
+ " Kts",
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
HUD_deque.push_front( p );
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
- strcpy(units, " ft");
+ strcpy(units, " ft");
} else {
- strcpy(units, " m");
+ strcpy(units, " m");
}
+ p = new instr_label( x_pos, 40, 40, 10,
+ get_altitude,
+ "%5.0f",
+ "Altitude ",
+ units,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.push_front( p );
+
p = new instr_label( x_pos, 25, 40, 10,
- get_altitude,
- "%5.0f",
- "Altitude ",
- units,
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
+ get_agl,
+ "%5.0f",
+ "Elvation ",
+ units,
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
HUD_deque.push_front( p );
p = new instr_label( x_pos, 10, 60, 10,
- get_heading,
- "%5.1f",
- "Heading ",
- " Deg",
- 1.0,
- HUDS_TOP,
- RIGHT_JUST,
- SMALL,
- 0,
- TRUE );
+ get_heading,
+ "%5.1f",
+ "Heading ",
+ " Deg",
+ 1.0,
+ HUDS_TOP,
+ RIGHT_JUST,
+ font_size,
+ 0,
+ TRUE );
+ HUD_deque.push_front( p );
+
+ p = new fgTBI_instr( 290, 55, 60, 10 ); // 270
+ HUD_deque.push_front( p );
+
+ p = new guage_instr( 270, //250, // x
+ 390, //360, //400, //45, //420, // y
+ 100, // width
+ 20, // height
+ get_aileronval, // data source
+ HUDS_BOTTOM | HUDS_NOTEXT,
+ 100.0,
+ +1.0,
+ -1.0);
+ HUD_deque.push_front( p );
+
+ p = new guage_instr( 20, // x
+ 240-50, // y
+ 20, // width
+ 100, // height
+ get_elevatorval, // data source
+ HUDS_RIGHT | HUDS_VERT | HUDS_NOTEXT,
+ -100.0, // Scale data
+ +1.0, // Data Range
+ -1.0);
+ HUD_deque.push_front( p );
+
+ p = new guage_instr( 270, //250, // x
+ 10+15, // y
+ 100, // width
+ 20, // height
+ get_rudderval, // data source
+ HUDS_TOP | HUDS_NOTEXT,
+ 100.0,
+ +1.0,
+ -1.0);
HUD_deque.push_front( p );
+ p = new guage_instr( 600, // x
+ 240-80,
+ 20,
+ 160, // height
+ get_throttleval, // data source
+ HUDS_VERT | HUDS_LEFT | HUDS_NOTEXT,
+ 100.0,
+ 1.0,
+ 0.0);
+ HUD_deque.push_front( p );
+
return 0; // For now. Later we may use this for an error code.
}
if( incr_bright ) {
switch (brightness) {
case BRT_LIGHT:
- current_options.set_hud_status(0);
+ current_options.set_hud_status(0);
break;
case BRT_MEDIUM:
case BRT_BLACK:
default:
- current_options.set_hud_status(0);
+ current_options.set_hud_status(0);
}
}
}
// all C++.
//
void fgUpdateHUD( void ) {
- int i;
+// int i;
int brightness;
// int day_night_sw = current_aircraft.controls->day_night_switch;
int day_night_sw = global_day_night_switch;
int hud_displays = HUD_deque.size();
instr_item *pHUDInstr;
+ int line_width;
if( !hud_displays ) { // Trust everyone, but ALWAYS cut the cards!
return;
}
+// vector < fgLineSeg2D > :: iterator first_lineSeg = HUD_LineList.begin();
+// vector < fgLineSeg2D > :: iterator last_lineSeg = HUD_LineList.end();
+// HUD_LineList.erase( first_lineSeg, last_lineSeg);
+ HUD_LineList.erase( HUD_LineList.begin(), HUD_LineList.end() );
+// first = HUD_StippleLineList.begin();
+// last = HUD_StippleLineList.end();
+// HUD_StippleLineList.erase( first, last);
+// HUD_StippleLineList.erase( HUD_StippleLineList.begin(),
+// HUD_StippleLineList.end() );
+#ifdef USE_HUD_TextList
+// vector < fgTextString > :: iterator first_string = HUD_TextList.begin();
+// vector < fgTextString > :: iterator last_string = HUD_TextList.end();
+// HUD_TextList.erase( first_string, last_string);
+ HUD_TextList.erase( HUD_TextList.begin(), HUD_TextList.end() );
+#endif
+
+ line_width = (current_options.get_xsize() > 1000) ? 2 : 1;
+
pHUDInstr = HUD_deque[0];
brightness = pHUDInstr->get_brightness();
// brightness = HUD_deque.at(0)->get_brightness();
glLoadIdentity();
gluOrtho2D(0, 640, 0, 480);
+// gluOrtho2D(0, 1024, 0, 768);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
- glLineWidth(1);
+ glLineWidth(line_width);
- HudIterator current = HUD_deque.begin();
- HudIterator last = HUD_deque.end();
-
- for ( ; current != last; ++current ) {
- pHUDInstr = *current;
-
- // for( i = hud_displays; i; --i) { // Draw everything
- // if( HUD_deque.at(i)->enabled()) {
- // pHUDInstr = HUD_deque[i - 1];
- if( pHUDInstr->enabled()) {
- // We should to respond to a dial instead
- // or as well to the of time of day. Of
- // course, we have no dial!
- if( day_night_sw == DAY) {
- switch (brightness) {
+ // We can do translucency, so why not. :-)
+// glEnable ( GL_BLEND ) ;
+// glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
+
+ if( day_night_sw == DAY) {
+ switch (brightness) {
case BRT_LIGHT:
glColor3f (0.1, 0.9, 0.1);
break;
break;
default:;
- }
- }
- else {
- if( day_night_sw == NIGHT) {
- switch (brightness) {
+ }
+ }
+ else {
+ if( day_night_sw == NIGHT) {
+ switch (brightness) {
case BRT_LIGHT:
glColor3f (0.9, 0.1, 0.1);
break;
case BRT_DARK:
default:
- glColor3f (0.5, 0.0, 0.0);
- }
- }
+ glColor3f (0.5, 0.0, 0.0);
+ }
+ }
else { // Just in case default
- glColor3f (0.1, 0.9, 0.1);
- }
+ glColor3f (0.1, 0.9, 0.1);
}
- // fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
- // hud->code, hud->status );
- pHUDInstr->draw();
-// HUD_deque.at(i)->draw(); // Responsible for broken or fixed variants.
+ }
+ deque < instr_item * > :: iterator current = HUD_deque.begin();
+ deque < instr_item * > :: iterator last = HUD_deque.end();
+
+ for ( ; current != last; ++current ) {
+ pHUDInstr = *current;
+
+ // for( i = hud_displays; i; --i) { // Draw everything
+ // if( HUD_deque.at(i)->enabled()) {
+ // pHUDInstr = HUD_deque[i - 1];
+ if( pHUDInstr->enabled()) {
+ // fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
+ // hud->code, hud->status );
+ pHUDInstr->draw();
+// HUD_deque.at(i)->draw(); // Responsible for broken or fixed variants.
// No broken displays honored just now.
}
- }
+ }
+
+ vector < fgLineSeg2D > :: iterator curSeg = HUD_LineList.begin();
+ vector < fgLineSeg2D > :: iterator lastSeg = HUD_LineList.end();
+
+ glBegin(GL_LINES);
+ for ( ; curSeg != lastSeg; curSeg++ ) {
+ curSeg->draw();
+ }
+ glEnd();
+
+// curSeg = HUD_StippleLineList.begin();
+// lastSeg = HUD_StippleLineList.end();
+
+// glEnable(GL_LINE_STIPPLE);
+// glLineStipple( 1, 0x00FF );
+// glBegin(GL_LINES);
+// for ( ; curSeg != lastSeg; curSeg++ ) {
+// curSeg->draw();
+// }
+// glEnd();
+// glDisable(GL_LINE_STIPPLE);
+#ifdef USE_HUD_TextList
+#define textString( x , y, text, font ) TextString( font, text, x , y )
+#endif
+
+#ifdef USE_HUD_TextList
+ GLfloat mat[16];
+ glPushMatrix();
+ glGetFloatv(GL_MODELVIEW_MATRIX, mat);
+ HUD_TextList.push_back( fgTextString( GLUT_BITMAP_8_BY_13,
+ get_formated_gmt_time(),
+ 450, 445)
+ );
+// glFontBegin ( myFont );
+ vector < fgTextString > :: iterator curString = HUD_TextList.begin();
+ vector < fgTextString > :: iterator lastString = HUD_TextList.end();
+
+ for ( ; curString != lastString; curString++ ) {
+ glLoadMatrixf( mat );
+ curString->draw();
+ }
+// glFontEnd ();
+ glPopMatrix();
+#endif
+
+// glDisable ( GL_BLEND ) ;
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
-
# include <values.h> // for MAXINT
#endif
-#include <deque> // STL double ended queue
#include <vector> // STL vector
+#include <deque> // STL double ended queue
#include <fg_typedefs.h>
#include <fg_constants.h>
#include <FDM/flight.hxx>
#include <Controls/controls.hxx>
+//#include "glfont.h"
+
+//extern GLFONT *myFont;
+
FG_USING_STD(deque);
FG_USING_STD(vector);
#define DASHED_NEG_LINES 12
-#define HORIZON_FIXED 1
-#define HORIZON_MOVING 2
-#define LABEL_COUNTER 1
-#define LABEL_WARNING 2
+#define HORIZON_FIXED 1
+#define HORIZON_MOVING 2
+#define LABEL_COUNTER 1
+#define LABEL_WARNING 2
#define HUDS_AUTOTICKS 0x0001
#define HUDS_VERT 0x0002
// Ladder orientaion
// #define HUD_VERTICAL 1
-// #define HUD_HORIZONTAL 2
-// #define HUD_FREEFLOAT 3
+// #define HUD_HORIZONTAL 2
+// #define HUD_FREEFLOAT 3
// Ladder orientation modes
-// #define HUD_LEFT 1
-// #define HUD_RIGHT 2
-// #define HUD_TOP 1
-// #define HUD_BOTTOM 2
-// #define HUD_V_LEFT 1
-// #define HUD_V_RIGHT 2
-// #define HUD_H_TOP 1
-// #define HUD_H_BOTTOM 2
+// #define HUD_LEFT 1
+// #define HUD_RIGHT 2
+// #define HUD_TOP 1
+// #define HUD_BOTTOM 2
+// #define HUD_V_LEFT 1
+// #define HUD_V_RIGHT 2
+// #define HUD_H_TOP 1
+// #define HUD_H_BOTTOM 2
// Ladder sub-types
-// #define HUD_LIM 1
-// #define HUD_NOLIM 2
-// #define HUD_CIRC 3
-
-// #define HUD_INSTR_LADDER 1
-// #define HUD_INSTR_CLADDER 2
-// #define HUD_INSTR_HORIZON 3
-// #define HUD_INSTR_LABEL 4
-
-extern double get_throttleval ( void );
-extern double get_aileronval ( void );
-extern double get_elevatorval ( void );
-extern double get_elev_trimval( void );
-extern double get_rudderval ( void );
-extern double get_speed ( void );
-extern double get_aoa ( void );
-extern double get_roll ( void );
-extern double get_pitch ( void );
-extern double get_heading ( void );
-extern double get_altitude ( void );
-extern double get_agl ( void );
-extern double get_sideslip ( void );
-extern double get_frame_rate ( void );
-extern double get_latitude ( void );
-extern double get_lat_min ( void );
-extern double get_longitude ( void );
-extern double get_long_min ( void );
-extern double get_fov ( void );
-extern double get_vfc_ratio ( void );
-extern double get_vfc_tris_drawn ( void );
-extern double get_climb_rate ( void );
+// #define HUD_LIM 1
+// #define HUD_NOLIM 2
+// #define HUD_CIRC 3
+
+// #define HUD_INSTR_LADDER 1
+// #define HUD_INSTR_CLADDER 2
+// #define HUD_INSTR_HORIZON 3
+// #define HUD_INSTR_LABEL 4
+
+// in cockpit.cxx
+extern float get_throttleval ( void );
+extern float get_aileronval ( void );
+extern float get_elevatorval ( void );
+extern float get_elev_trimval( void );
+extern float get_rudderval ( void );
+extern float get_speed ( void );
+extern float get_aoa ( void );
+extern float get_roll ( void );
+extern float get_pitch ( void );
+extern float get_heading ( void );
+extern float get_view_direction( void );
+extern float get_altitude ( void );
+extern float get_agl ( void );
+extern float get_sideslip ( void );
+extern float get_frame_rate ( void );
+extern float get_latitude ( void );
+extern float get_lat_min ( void );
+extern float get_longitude ( void );
+extern float get_long_min ( void );
+extern float get_fov ( void );
+extern float get_vfc_ratio ( void );
+extern float get_vfc_tris_drawn ( void );
+extern float get_vfc_tris_culled ( void );
+extern float get_climb_rate ( void );
+extern char *coord_format_lat(float);
+extern char *coord_format_lon(float);
+//extern char *coord_format_latlon(float latitude, float longitude); // cockpit.cxx
+
+extern char *get_formated_gmt_time( void );
enum hudinstype{ HUDno_instr,
HUDscale,
GLfloat Green;
GLfloat Red;
} glRGBTRIPLE;
+/*
+struct fgVertex2D {
+ UINT x, y;
+
+ fgVertex2D( UINT a = 0, UINT b =0 )
+ : x(a), y(b) {}
+
+ fgVertex2D( const fgVertex2D & image )
+ : x(image.x), y(image.y) {}
+
+ fgVertex2D& operator= ( const fgVertex2D & image ) {
+ x = image.x; y = image.y; return *this;
+ }
+
+ ~fgVertex2D() {}
+};
+*/
+class fgLineSeg2D {
+private:
+ GLfloat x0, y0, x1, y1; //UINT
+
+public:
+ fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
+ : x0(a), y0(b), x1(c), y1(d) {}
+
+ fgLineSeg2D( const fgLineSeg2D & image )
+ : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
+
+ fgLineSeg2D& operator= ( const fgLineSeg2D & image ) {
+ x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
+ }
+
+ ~fgLineSeg2D() {}
+
+ void draw()
+ {
+ glVertex2f(x0, y0);
+ glVertex2f(x1, y1);
+ }
+};
+
+#define USE_HUD_TextList
+#ifdef USE_HUD_TextList
+
+//#define FAST_TEXT_TEST
+#ifdef FAST_TEXT_TEST
+extern void Font_Setup(void);
+extern unsigned int font_base;
+#endif
+
+class fgTextString {
+private:
+ void *font;
+ char msg[80];
+ float x, y;
+// static GLfloat mat[16];
+
+public:
+ fgTextString( void *d = NULL, char *c = NULL, UINT x = 0, UINT y =0 )
+ : font(d), x(x), y(y) {strcpy(msg,c);}
+
+ fgTextString( const fgTextString & image )
+ : font(image.font), x(image.x), y(image.y) {strcpy(msg,image.msg);}
+
+ fgTextString& operator = ( const fgTextString & image ) {
+ font = image.font; strcpy(msg,image.msg); x = image.x; y = image.y;
+ return *this;
+ }
+
+ ~fgTextString() {msg[0]='\0';}
+
+// void set_mat(void) {
+// glScalef(.075, .075, 0.0);
+// glGetFloatv(GL_MODELVIEW_MATRIX, mat);
+// }
+
+
+ void draw()
+ {
+#ifdef FAST_TEXT_TEST
+ glRasterPos2f( x, y);
+ int len = (int) strlen(msg);
+ for (int i=0; i < len; i++) {
+ glCallList(font_base+msg[i]);
+ }
+// glFontTextOut ( msg, x, y, 0.0f);
+
+#else
+#define USE_STROKED_CHAR
+#ifdef USE_STROKED_CHAR
+ int c;
+ char *buf;
+ buf = msg;
+ if(*buf)
+ {
+// glRasterPos2f( x, y);
+ glTranslatef( x, y, 0);
+ glScalef(.075, .075, 0.0);
+ while ((c=*buf++)) {
+ glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
+ }
+ }
+#else
+ char *c = msg;
+ if(*c)
+ {
+ glRasterPos2f(x, y);
+ while (*c) {
+ glutBitmapCharacter(font, *c);
+ c++;
+ }
+ }
+#endif // #ifdef USE_STROKED_CHAR
+#endif // FAST_TEXT_TEST
+ }
+};
+
+typedef vector< fgTextString > TYPE_HUD_TextList;
+extern TYPE_HUD_TextList HUD_TextList;
+#endif //#ifdef USE_HUD_TextList
+
+
+typedef vector< fgLineSeg2D > TYPE_HUD_LineList;
+extern TYPE_HUD_LineList HUD_LineList;
+extern TYPE_HUD_LineList HUD_StippleLineList;
class instr_item { // An Abstract Base Class (ABC)
private:
UINT handle;
RECT scrn_pos; // Framing - affects scale dimensions
// and orientation. Vert vs Horz, etc.
- DBLFNPTR load_value_fn;
- double disp_factor; // Multiply by to get numbers shown on scale.
+ FLTFNPTR load_value_fn;
+ float disp_factor; // Multiply by to get numbers shown on scale.
UINT opts;
bool is_enabled;
bool broken;
int y,
UINT height,
UINT width,
- DBLFNPTR data_source,
- double data_scaling,
+ FLTFNPTR data_source,
+ float data_scaling,
UINT options,
bool working = true);
bool is_broken ( void ) { return broken; }
bool enabled ( void ) { return is_enabled;}
bool data_available ( void ) { return !!load_value_fn; }
- double get_value ( void ) { return load_value_fn(); }
- double data_scaling ( void ) { return disp_factor; }
+ float get_value ( void ) { return load_value_fn(); }
+ float data_scaling ( void ) { return disp_factor; }
UINT get_span ( void ) { return scr_span; }
POINT get_centroid ( void ) { return mid_span; }
UINT get_options ( void ) { return opts; }
+ UINT huds_vert (UINT options) { return( options & HUDS_VERT ); }
+ UINT huds_left (UINT options) { return( options & HUDS_LEFT ); }
+ UINT huds_right (UINT options) { return( options & HUDS_RIGHT ); }
+ UINT huds_both (UINT options) { return( (options & HUDS_BOTH) == HUDS_BOTH ); }
+ UINT huds_noticks (UINT options) { return( options & HUDS_NOTICKS ); }
+ UINT huds_notext (UINT options) { return( options & HUDS_NOTEXT ); }
+ UINT huds_top (UINT options) { return( options & HUDS_TOP ); }
+ UINT huds_bottom (UINT options) { return( options & HUDS_BOTTOM ); }
+
virtual void display_enable( bool working ) { is_enabled = !! working;}
-
virtual void update( void );
virtual void break_display ( bool bad );
virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
void SetPosition ( int x, int y, UINT width, UINT height );
UINT get_Handle( void );
virtual void draw( void ) = 0; // Required method in derived classes
+
+ void drawOneLine( UINT x1, UINT y1, UINT x2, UINT y2)
+ {
+ HUD_LineList.push_back(fgLineSeg2D(x1,y1,x2,y2));
+// glBegin(GL_LINES);
+// glVertex2i(x1, y1);
+// glVertex2i(x2, y2);
+// glEnd();
+ }
+ void drawOneStippleLine( UINT x1, UINT y1, UINT x2, UINT y2)
+ {
+ HUD_StippleLineList.push_back(fgLineSeg2D(x1,y1,x2,y2));
+// glEnable(GL_LINE_STIPPLE);
+// glLineStipple( 1, 0x00FF );
+// glBegin(GL_LINES);
+// glVertex2i(x1, y1);
+// glVertex2i(x2, y2);
+// glEnd();
+// glDisable(GL_LINE_STIPPLE);
+ }
+#ifdef USE_HUD_TextList
+ void TextString( void *font, char *msg, UINT x, UINT y )
+ {
+ HUD_TextList.push_back(fgTextString(font, msg, x, y));
+ }
+#endif
};
-typedef deque< instr_item * > HudContainerType;
-typedef HudContainerType::iterator HudIterator;
-
typedef instr_item *HIptr;
-extern HudContainerType HUD_deque;
+//typedef deque < instr_item * > hud_deque_type;
+//typedef hud_deque_type::iterator hud_deque_iterator;
+//typedef hud_deque_type::const_iterator hud_deque_const_iterator;
+
+extern deque< instr_item *> HUD_deque;
+//extern hud_deque_type HUD_deque;
// instr_item This class has no other purpose than to maintain
// a linked list of instrument and derived class
fgLabelJust justify;
int fontSize;
int blink;
+ char format_buffer[80];
public:
instr_label( int x,
int y,
UINT width,
UINT height,
- DBLFNPTR data_source,
+ FLTFNPTR data_source,
const char *label_format,
const char *pre_label_string = 0,
const char *post_label_string = 0,
- double scale_data = 1.0,
+ float scale_data = 1.0,
UINT options = HUDS_TOP,
fgLabelJust justification = CENTER_JUST,
int font_size = SMALL,
typedef instr_label * pInstlabel;
+
+class lat_label : public instr_item {
+ private:
+ const char *pformat;
+ const char *pre_str;
+ const char *post_str;
+ fgLabelJust justify;
+ int fontSize;
+ int blink;
+ char format_buffer[80];
+
+ public:
+ lat_label( int x,
+ int y,
+ UINT width,
+ UINT height,
+ FLTFNPTR data_source,
+ const char *label_format,
+ const char *pre_label_string = 0,
+ const char *post_label_string = 0,
+ float scale_data = 1.0,
+ UINT options = HUDS_TOP,
+ fgLabelJust justification = CENTER_JUST,
+ int font_size = SMALL,
+ int blinking = NOBLINK,
+ bool working = true);
+
+ ~lat_label();
+
+ lat_label( const lat_label & image);
+ lat_label & operator = (const lat_label & rhs );
+ virtual void draw( void ); // Required method in base class
+};
+
+typedef lat_label * pLatlabel;
+
+class lon_label : public instr_item {
+ private:
+ const char *pformat;
+ const char *pre_str;
+ const char *post_str;
+ fgLabelJust justify;
+ int fontSize;
+ int blink;
+ char format_buffer[80];
+
+ public:
+ lon_label( int x,
+ int y,
+ UINT width,
+ UINT height,
+ FLTFNPTR data_source,
+ const char *label_format,
+ const char *pre_label_string = 0,
+ const char *post_label_string = 0,
+ float scale_data = 1.0,
+ UINT options = HUDS_TOP,
+ fgLabelJust justification = CENTER_JUST,
+ int font_size = SMALL,
+ int blinking = NOBLINK,
+ bool working = true);
+
+ ~lon_label();
+
+ lon_label( const lon_label & image);
+ lon_label & operator = (const lon_label & rhs );
+ virtual void draw( void ); // Required method in base class
+};
+
+typedef lon_label * pLonlabel;
+
//
// instr_scale This class is an abstract base class for both moving
// scale and moving needle (fixed scale) indicators. It
class instr_scale : public instr_item {
private:
- double range_shown; // Width Units.
- double Maximum_value; // ceiling.
- double Minimum_value; // Representation floor.
- double scale_factor; // factor => screen units/range values.
+ float range_shown; // Width Units.
+ float Maximum_value; // ceiling.
+ float Minimum_value; // Representation floor.
+ float scale_factor; // factor => screen units/range values.
UINT Maj_div; // major division marker units
UINT Min_div; // minor division marker units
UINT Modulo; // Roll over point
int y,
UINT width,
UINT height,
- DBLFNPTR load_fn,
+ FLTFNPTR load_fn,
UINT options,
- double show_range,
- double max_value = 100.0,
- double min_value = 0.0,
- double disp_scaling = 1.0,
+ float show_range,
+ float max_value = 100.0,
+ float min_value = 0.0,
+ float disp_scaling = 1.0,
UINT major_divs = 10,
UINT minor_divs = 5,
UINT rollover = 0,
virtual void draw ( void ) {}; // No-op here. Defined in derived classes.
UINT div_min ( void ) { return Min_div;}
UINT div_max ( void ) { return Maj_div;}
- double min_val ( void ) { return Minimum_value;}
- double max_val ( void ) { return Maximum_value;}
+ float min_val ( void ) { return Minimum_value;}
+ float max_val ( void ) { return Maximum_value;}
UINT modulo ( void ) { return Modulo; }
- double factor ( void ) { return scale_factor;}
- double range_to_show( void ) { return range_shown;}
+ float factor ( void ) { return scale_factor;}
+ float range_to_show( void ) { return range_shown;}
};
// hud_card_ This class displays the indicated quantity on
class hud_card : public instr_scale {
private:
- double val_span;
- double half_width_units;
-
+ float val_span;
+ float half_width_units;
+
public:
hud_card( int x,
int y,
UINT width,
UINT height,
- DBLFNPTR load_fn,
+ FLTFNPTR load_fn,
UINT options,
- double maxValue = 100.0,
- double minValue = 0.0,
- double disp_scaling = 1.0,
+ float maxValue = 100.0,
+ float minValue = 0.0,
+ float disp_scaling = 1.0,
UINT major_divs = 10,
UINT minor_divs = 5,
UINT modulator = 100,
int dp_showing = 2,
- double value_span = 100.0,
+ float value_span = 100.0,
bool working = true);
~hud_card();
typedef hud_card * pCardScale;
class guage_instr : public instr_scale {
- private:
-
public:
guage_instr( int x,
int y,
UINT width,
UINT height,
- DBLFNPTR load_fn,
+ FLTFNPTR load_fn,
UINT options,
- double disp_scaling = 1.0,
- double maxValue = 100,
- double minValue = 0,
+ float disp_scaling = 1.0,
+ float maxValue = 100,
+ float minValue = 0,
UINT major_divs = 50,
UINT minor_divs = 0,
int dp_showing = 2,
class dual_instr_item : public instr_item {
private:
- DBLFNPTR alt_data_source;
+ FLTFNPTR alt_data_source;
public:
dual_instr_item ( int x,
int y,
UINT width,
UINT height,
- DBLFNPTR chn1_source,
- DBLFNPTR chn2_source,
+ FLTFNPTR chn1_source,
+ FLTFNPTR chn2_source,
bool working = true,
UINT options = HUDS_TOP);
dual_instr_item( const dual_instr_item & image);
dual_instr_item & operator = (const dual_instr_item & rhs );
- double current_ch1( void ) { return alt_data_source();}
- double current_ch2( void ) { return get_value();}
+ float current_ch1( void ) { return (float)alt_data_source();}
+ float current_ch2( void ) { return (float)get_value();}
virtual void draw ( void ) { }
};
int y,
UINT width,
UINT height,
- DBLFNPTR chn1_source = get_roll,
- DBLFNPTR chn2_source = get_sideslip,
- double maxBankAngle = 45.0,
- double maxSlipAngle = 5.0,
- UINT gap_width = 5.0,
+ FLTFNPTR chn1_source = get_roll,
+ FLTFNPTR chn2_source = get_sideslip,
+ float maxBankAngle = 45.0,
+ float maxSlipAngle = 5.0,
+ UINT gap_width = 5,
bool working = true);
fgTBI_instr( const fgTBI_instr & image);
UINT minor_div;
UINT label_pos;
UINT scr_hole;
- double vmax;
- double vmin;
- double factor;
+ float vmax;
+ float vmin;
+ float factor;
public:
HudLadder( int x,
int y,
UINT width,
UINT height,
- DBLFNPTR ptch_source = get_roll,
- DBLFNPTR roll_source = get_pitch,
- double span_units = 45.0,
- double division_units = 10.0,
- double minor_division = 0.0,
+ FLTFNPTR ptch_source = get_roll,
+ FLTFNPTR roll_source = get_pitch,
+ float span_units = 45.0,
+ float division_units = 10.0,
+ float minor_division = 0.0,
UINT screen_hole = 70,
UINT lbl_pos = 0,
bool working = true );
char *msg,
void *font = GLUT_STROKE_ROMAN,
float theta = 0);
+//extern void strokeString(float xx,
+// float yy,
+// char *msg,
+// void *font = GLUT_STROKE_ROMAN)
+
/*
bool AddHUDInstrument( instr_item *pBlackBox );
void DrawHUD ( void );
*/
#endif // _HUD_H
-
#include <stdlib.h>
#include <string.h>
#include <Aircraft/aircraft.hxx>
+#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Math/fg_random.h>
#include <Math/mat3.h>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
-
#include "hud.hxx"
+
+#ifdef USE_HUD_TextList
+#define textString( x , y, text, font ) TextString( font, text, x , y )
+#endif
+
//========== Top of hud_card class member definitions =============
hud_card ::
int y,
UINT width,
UINT height,
- DBLFNPTR data_source,
+ FLTFNPTR data_source,
UINT options,
- double max_value,
- double min_value,
- double disp_scaling,
+ float max_value, // 360
+ float min_value, // 0
+ float disp_scaling,
UINT major_divs,
UINT minor_divs,
- UINT modulus,
+ UINT modulus, // 360
int dp_showing,
- double value_span,
+ float value_span,
bool working) :
instr_scale( x,y,width,height,
data_source, options,
val_span ( value_span)
{
half_width_units = range_to_show() / 2.0;
+// UINT options = get_options();
+// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
+// huds_right = options & HUDS_RIGHT;
+// huds_left = options & HUDS_LEFT;
+// huds_vert = options & HUDS_VERT;
+// huds_notext = options & HUDS_NOTEXT;
+// huds_top = options & HUDS_TOP;
+// huds_bottom = options & HUDS_BOTTOM;
}
hud_card ::
val_span( image.val_span),
half_width_units (image.half_width_units)
{
+// UINT options = get_options();
+// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
+// huds_right = options & HUDS_RIGHT;
+// huds_left = options & HUDS_LEFT;
+// huds_vert = options & HUDS_VERT;
+// huds_notext = options & HUDS_NOTEXT;
+// huds_top = options & HUDS_TOP;
+// huds_bottom = options & HUDS_BOTTOM;
}
hud_card & hud_card ::
void hud_card ::
draw( void ) // (HUD_scale * pscale )
{
- double vmin, vmax;
+ float vmin, vmax;
int marker_xs;
int marker_xe;
int marker_ys;
int marker_ye;
- /* register */ int i;
+ int lenstr;
+ int height, width;
+ int i, last;
char TextScale[80];
bool condition;
int disp_val = 0;
POINT mid_scr = get_centroid();
- double cur_value = get_value();
+ float cur_value = get_value();
RECT scrn_rect = get_location();
UINT options = get_options();
+ height = scrn_rect.top + scrn_rect.bottom;
+ width = scrn_rect.left + scrn_rect.right;
+
vmin = cur_value - half_width_units; // width units == needle travel
vmax = cur_value + half_width_units; // or picture unit span.
- // Draw the basic markings for the scale...
-
- if( options & HUDS_VERT ) { // Vertical scale
+
+ // Draw the basic markings for the scale...
+
+ if( huds_vert(options) ) { // Vertical scale
drawOneLine( scrn_rect.left, // Bottom tick bar
scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
+ width,
scrn_rect.top);
drawOneLine( scrn_rect.left, // Top tick bar
- scrn_rect.top + scrn_rect.bottom,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom );
-
- marker_xs = scrn_rect.left;
- marker_xe = scrn_rect.left + scrn_rect.right;
+ height,
+ width,
+ height );
+
+ marker_xs = scrn_rect.left; // x start
+ marker_xe = width; // x extent
+ marker_ye = height;
+
+// glBegin(GL_LINES);
+
+ // Bottom tick bar
+// glVertex2f( marker_xs, scrn_rect.top);
+// glVertex2f( marker_xe, scrn_rect.top);
+
+ // Top tick bar
+// glVertex2f( marker_xs, marker_ye);
+// glVertex2f( marker_xe, marker_ye );
+// glEnd();
// We do not use else in the following so that combining the two
// options produces a "caged" display with double carrots. The
// same is done for horizontal card indicators.
- if( options & HUDS_LEFT ) { // Calculate x marker offset
- drawOneLine( scrn_rect.left + scrn_rect.right,
- scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom); // Cap right side
+ if( huds_left(options) ) { // Calculate x marker offset
+ drawOneLine( marker_xe, scrn_rect.top,
+ marker_xe, marker_ye); // Cap right side
- marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
+ marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
// Indicator carrot
- drawOneLine( marker_xs, mid_scr.y,
- marker_xe, mid_scr.y + scrn_rect.right / 6);
- drawOneLine( marker_xs, mid_scr.y,
- marker_xe, mid_scr.y - scrn_rect.right / 6);
-
- }
- if( options & HUDS_RIGHT ) { // We'll default this for now.
- drawOneLine( scrn_rect.left,
- scrn_rect.top,
- scrn_rect.left,
- scrn_rect.top + scrn_rect.bottom); // Cap left side
+// drawOneLine( marker_xs, mid_scr.y,
+// marker_xe, mid_scr.y + scrn_rect.right / 6);
+// drawOneLine( marker_xs, mid_scr.y,
+// marker_xe, mid_scr.y - scrn_rect.right / 6);
+
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( marker_xe, mid_scr.y + scrn_rect.right / 6);
+ glVertex2f( marker_xs, mid_scr.y);
+ glVertex2f( marker_xe, mid_scr.y - scrn_rect.right / 6);
+ glEnd();
+ }
+ if( huds_right(options) ) { // We'll default this for now.
+ drawOneLine( scrn_rect.left, scrn_rect.top,
+ scrn_rect.left, marker_ye ); // Cap left side
- marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
+ marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
// Indicator carrot
- drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
- marker_xe, mid_scr.y );
- drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
- marker_xe, mid_scr.y);
- }
+// drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
+// marker_xe, mid_scr.y );
+// drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
+// marker_xe, mid_scr.y);
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( scrn_rect.left, mid_scr.y + scrn_rect.right / 6);
+ glVertex2f( marker_xe, mid_scr.y );
+ glVertex2f( scrn_rect.left, mid_scr.y - scrn_rect.right / 6);
+ glEnd();
+ }
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
- if(( options & HUDS_BOTH) == HUDS_BOTH) {
+ if(huds_both(options)) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
- for( i = (int)vmin; i <= (int)vmax; i++ ) {
+// last = FloatToInt(vmax)+1;
+// i = FloatToInt(vmin);
+ last = (int)vmax + 1;
+ i = (int)vmin;
+ for( ; i <last ; i++ )
+ {
condition = true;
if( !modulo()) {
if( i < min_val()) {
if( condition ) { // Show a tick if necessary
// Calculate the location of this tick
- marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
-
+ marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
+// marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
// Block calculation artifact from drawing ticks below min coordinate.
// Calculation here accounts for text height.
if(( marker_ys < (scrn_rect.top + 4)) |
- ( marker_ys > (scrn_rect.top + scrn_rect.bottom - 4))) {
+ ( marker_ys > (height - 4))) {
// Magic numbers!!!
continue;
}
if( div_min()) {
- if( (i%div_min()) == 0) {
+// if( (i%div_min()) == 0) {
+ if( !(i%(int)div_min())) {
if((( marker_ys - 5) > scrn_rect.top ) &&
- (( marker_ys + 5) < (scrn_rect.top + scrn_rect.bottom))){
- if( (options & HUDS_BOTH) == HUDS_BOTH ) {
+ (( marker_ys + 5) < (height))){
+ if( huds_both(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs, marker_ys );
drawOneLine( marker_xe, marker_ys,
- scrn_rect.left + scrn_rect.right, marker_ys );
- }
+ width, marker_ys );
+// glBegin(GL_LINES);
+// glVertex2f( scrn_rect.left, marker_ys );
+// glVertex2f( marker_xs, marker_ys );
+// glVertex2f( marker_xe, marker_ys);
+// glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
+// glEnd();
+ }
else {
- if( options & HUDS_LEFT ) {
+ if( huds_left(options) ) {
drawOneLine( marker_xs + 4, marker_ys,
marker_xe, marker_ys );
}
}
}
}
- if( div_max()) {
- if( !(i%(int)div_max())){
+ if( div_max() ) {
+ if( !(i%(int)div_max()) )
+ {
if(modulo()) {
- if( disp_val < 0) {
- disp_val += modulo();
- }
- else {
- disp_val = i % modulo();
+ if( disp_val < 0) {
+ while(disp_val < 0)
+ disp_val += modulo();
+// } else {
+// disp_val = i % (int)modulo();
}
- }
- else {
- disp_val = i;
- }
- sprintf( TextScale, "%d", (int)(disp_val * data_scaling() +.5));
+ disp_val = i % (int) modulo(); // ?????????
+ } else {
+ disp_val = i;
+ }
+
+ lenstr = sprintf( TextScale, "%d",
+ FloatToInt(disp_val * data_scaling()/*+.5*/));
+// (int)(disp_val * data_scaling() +.5));
if(( (marker_ys - 8 ) > scrn_rect.top ) &&
- ( (marker_ys + 8) < (scrn_rect.top + scrn_rect.bottom))){
- if( (options & HUDS_BOTH) == HUDS_BOTH) {
- drawOneLine( scrn_rect.left, marker_ys,
- marker_xs, marker_ys);
- drawOneLine( marker_xs, marker_ys,
- scrn_rect.left + scrn_rect.right,
- marker_ys);
- if( !(options & HUDS_NOTEXT)) {
- textString ( marker_xs + 2, marker_ys,
- TextScale, GLUT_BITMAP_8_BY_13 );
+ ( (marker_ys + 8) < (height))){
+ if( huds_both(options) ) {
+// drawOneLine( scrn_rect.left, marker_ys,
+// marker_xs, marker_ys);
+// drawOneLine( marker_xs, marker_ys,
+// scrn_rect.left + scrn_rect.right,
+// marker_ys);
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( scrn_rect.left, marker_ys );
+ glVertex2f( marker_xs, marker_ys);
+ glVertex2f( width, marker_ys);
+ glEnd();
+ if( !huds_notext(options)) {
+ textString ( marker_xs + 2, marker_ys,
+ TextScale, GLUT_BITMAP_8_BY_13 );
}
- }
+ }
else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
- if( !(options & HUDS_NOTEXT)) {
- if( options & HUDS_LEFT ) {
- textString( marker_xs - 8 * strlen(TextScale) - 2,
- marker_ys - 4,
- TextScale, GLUT_BITMAP_8_BY_13 );
+ if( !huds_notext(options) ) {
+ if( huds_left(options) ) {
+ textString( marker_xs - 8 * lenstr - 2,
+ marker_ys - 4,
+ TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
- textString( marker_xe + 3 * strlen(TextScale),
- marker_ys - 4,
- TextScale, GLUT_BITMAP_8_BY_13 );
- }
+ textString( marker_xe + 3 * lenstr,
+ marker_ys - 4,
+ TextScale, GLUT_BITMAP_8_BY_13 );
+ }
}
}
} // Else read oriented right
} // End for range of i from vmin to vmax
} // End if VERTICAL SCALE TYPE
else { // Horizontal scale by default
- drawOneLine( scrn_rect.left, // left tick bar
- scrn_rect.top,
- scrn_rect.left,
- scrn_rect.top + scrn_rect.bottom);
-
- drawOneLine( scrn_rect.left + scrn_rect.right, // right tick bar
- scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom );
-
- marker_ys = scrn_rect.top; // Starting point for
- marker_ye = scrn_rect.top + scrn_rect.bottom; // tick y location calcs
-
- if( options & HUDS_TOP ) {
- drawOneLine( scrn_rect.left,
- scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top); // Bottom box line
-
- marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
- // Bottom arrow
- drawOneLine( mid_scr.x, marker_ye,
- mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
- drawOneLine( mid_scr.x, marker_ye,
- mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
- }
- if( options & HUDS_BOTTOM) {
- drawOneLine( scrn_rect.left,
- scrn_rect.top + scrn_rect.bottom,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom); // Top box line
- // Tick point adjust
- marker_ys = scrn_rect.top +
- scrn_rect.bottom - scrn_rect.bottom / 2;
- // Top arrow
- drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
- scrn_rect.top + scrn_rect.bottom,
- mid_scr.x ,
- marker_ys );
- drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
- scrn_rect.top + scrn_rect.bottom,
- mid_scr.x ,
- marker_ys );
- }
+ // left tick bar
+ drawOneLine( scrn_rect.left, scrn_rect.top,
+ scrn_rect.left, height);
+
+ // right tick bar
+ drawOneLine( width, scrn_rect.top,
+ width,
+ height );
+
+ marker_ys = scrn_rect.top; // Starting point for
+ marker_ye = height; // tick y location calcs
+ marker_xe = width;
+
+// glBegin(GL_LINES);
+ // left tick bar
+// glVertex2f( scrn_rect.left, scrn_rect.top);
+// glVertex2f( scrn_rect.left, marker_ye);
+
+ // right tick bar
+// glVertex2f( marker_xe, scrn_rect.top);
+// glVertex2f( marker_xe, marker_ye );
+// glEnd();
+
+ if( huds_top(options) ) {
+ // Bottom box line
+ drawOneLine( scrn_rect.left,
+ scrn_rect.top,
+ width,
+ scrn_rect.top);
+
+ // Tick point adjust
+ marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
+
+ // Bottom arrow
+// drawOneLine( mid_scr.x, marker_ye,
+// mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
+// drawOneLine( mid_scr.x, marker_ye,
+// mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
+
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
+ glVertex2f( mid_scr.x, marker_ye);
+ glVertex2f( mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
+ glEnd();
+ }
+ if( huds_bottom(options) ) {
+ // Top box line
+ drawOneLine( scrn_rect.left, height,
+ width, height);
+ // Tick point adjust
+ marker_ys = height - scrn_rect.bottom / 2;
+
+ // Top arrow
+// drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
+// scrn_rect.top + scrn_rect.bottom,
+// mid_scr.x, marker_ys );
+// drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
+// scrn_rect.top + scrn_rect.bottom,
+// mid_scr.x , marker_ys );
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( mid_scr.x + scrn_rect.bottom / 4,
+ height);
+ glVertex2f( mid_scr.x , marker_ys );
+ glVertex2f( mid_scr.x - scrn_rect.bottom / 4,
+ height);
+ glEnd();
+ }
// if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
// marker_xe = marker_ys;
// }
// printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
- for( i = (int)vmin; i <= (int)vmax; i++ ) {
+
+// last = FloatToInt(vmax)+1;
+// i = FloatToInt(vmin);
+ last = (int)vmax + 1;
+ i = (int)vmin;
+ for(; i <last ; i++ ) {
+// for( i = (int)vmin; i <= (int)vmax; i++ ) {
// printf("<*> i = %d\n", i);
condition = true;
if( !modulo()) {
}
// printf("<**> i = %d\n", i);
if( condition ) {
- marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
+// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
+ marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
if( div_min()){
- if( (i%(int)div_min()) == 0 ) {
+// if( (i%(int)div_min()) == 0 ) {
+ if( !(i%(int)div_min() )) {
// draw in ticks only if they aren't too close to the edge.
if((( marker_xs - 5) > scrn_rect.left ) &&
(( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
- if( (options & HUDS_BOTH) == HUDS_BOTH ) {
+ if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
drawOneLine( marker_xs, marker_ye + 4,
- marker_xs, scrn_rect.top + scrn_rect.bottom);
- }
+ marker_xs, height);
+// glBegin(GL_LINES);
+// glVertex2f( marker_xs, scrn_rect.top);
+// glVertex2f( marker_xs, marker_ys - 4);
+// glVertex2f( marker_xs, marker_ye + 4);
+// glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
+// glEnd();
+ }
else {
- if( options & HUDS_TOP) {
+ if( huds_top(options)) {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye - 4);
}
}
}
}
- // printf("<***> i = %d\n", i);
+ // printf("<***> i = %d\n", i);
if( div_max()) {
- // printf("i = %d\n", i);
- if( (i%(int)div_max())==0 ) {
+ // printf("i = %d\n", i);
+// if( (i%(int)div_max())==0 ) {
+ if( !(i%(int)div_max()) ) {
if(modulo()) {
if( disp_val < 0) {
- disp_val += modulo();
- }
- else {
- disp_val = i % modulo();
- }
+ while(disp_val<0)
+ disp_val += modulo();
}
- else {
+ disp_val = i % (int) modulo(); // ?????????
+ } else {
disp_val = i;
- }
- // printf("disp_val = %d\n", disp_val);
- // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
- sprintf( TextScale, "%d", (int)(disp_val * data_scaling() +.5));
+ }
+ // printf("disp_val = %d\n", disp_val);
+ // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
+ lenstr = sprintf( TextScale, "%d",
+// (int)(disp_val * data_scaling() +.5));
+ FloatToInt(disp_val * data_scaling()/*+.5*/));
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
- if( (options & HUDS_BOTH) == HUDS_BOTH) {
- drawOneLine( marker_xs, scrn_rect.top,
- marker_xs, marker_ys);
- drawOneLine( marker_xs, marker_ye,
- marker_xs, scrn_rect.top + scrn_rect.bottom);
-
- if( !(options & HUDS_NOTEXT)) {
- textString ( marker_xs - 4 * strlen(TextScale),
+ if( huds_both(options) ) {
+// drawOneLine( marker_xs, scrn_rect.top,
+// marker_xs, marker_ys);
+// drawOneLine( marker_xs, marker_ye,
+// marker_xs, scrn_rect.top + scrn_rect.bottom);
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( marker_xs, scrn_rect.top);
+ glVertex2f( marker_xs, marker_ye);
+ glVertex2f( marker_xs, height);
+ glEnd();
+ if( !huds_notext(options) ) {
+ textString ( marker_xs - 4 * lenstr,
marker_ys + 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
- if( !(options & HUDS_NOTEXT)) {
- if( options & HUDS_TOP ) {
- textString ( marker_xs - 4 * strlen(TextScale),
- scrn_rect.top + scrn_rect.bottom - 10,
+ if( !huds_notext(options)) {
+ if( huds_top(options) ) {
+ textString ( marker_xs - 4 * lenstr,
+ height - 10,
TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
- textString( marker_xs - 4 * strlen(TextScale),
+ textString( marker_xs - 4 * lenstr,
scrn_rect.top,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
}
}
- }
- // printf("<****> i = %d\n", i);
+ }
+ // printf("<****> i = %d\n", i);
}
}
}
int y,
UINT width,
UINT height,
- DBLFNPTR chn1_source,
- DBLFNPTR chn2_source,
+ FLTFNPTR chn1_source,
+ FLTFNPTR chn2_source,
bool working,
UINT options ):
instr_item( x, y, width, height,
#include <stdlib.h>
#include <string.h>
#include <Aircraft/aircraft.hxx>
+#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Math/fg_random.h>
#include <Math/mat3.h>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
-
#include "hud.hxx"
+
+#ifdef USE_HUD_TextList
+#define textString( x , y, text, font ) TextString( font, text, x , y )
+#endif
+
//============== Top of guage_instr class member definitions ==============
guage_instr ::
int y,
UINT width,
UINT height,
- DBLFNPTR load_fn,
+ FLTFNPTR load_fn,
UINT options,
- double disp_scale,
- double maxValue,
- double minValue,
+ float disp_scale,
+ float maxValue,
+ float minValue,
UINT major_divs,
UINT minor_divs,
int dp_showing,
modulus, dp_showing,
working)
{
+// UINT options = get_options();
+// huds_vert = options & HUDS_VERT;
+// huds_left = options & HUDS_LEFT;
+// huds_right = options & HUDS_RIGHT;
+// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
+// huds_noticks = options & HUDS_NOTICKS;
+// huds_notext = options & HUDS_NOTEXT;
+// huds_top = options & HUDS_TOP;
+// huds_bottom = options & HUDS_BOTTOM;
}
guage_instr ::
guage_instr( const guage_instr & image):
instr_scale( (instr_scale &) image)
{
+// UINT options = get_options();
+// huds_vert = options & HUDS_VERT;
+// huds_left = options & HUDS_LEFT;
+// huds_right = options & HUDS_RIGHT;
+// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
+// huds_noticks = options & HUDS_NOTICKS;
+// huds_notext = options & HUDS_NOTEXT;
+// huds_top = options & HUDS_TOP;
+// huds_bottom = options & HUDS_BOTTOM;
}
guage_instr & guage_instr ::
int marker_xs, marker_xe;
int marker_ys, marker_ye;
int text_x, text_y;
+ int width, height, bottom_4;
+ int lenstr;
int i;
char TextScale[80];
bool condition;
- int disp_val;
- double vmin = min_val();
- double vmax = max_val();
+ int disp_val = 0;
+ float vmin = min_val();
+ float vmax = max_val();
POINT mid_scr = get_centroid();
- double cur_value = get_value();
+ float cur_value = get_value();
RECT scrn_rect = get_location();
- UINT options = get_options();
+ UINT options = get_options();
+
+ width = scrn_rect.left + scrn_rect.right;
+ height = scrn_rect.top + scrn_rect.bottom;
+ bottom_4 = scrn_rect.bottom / 4;
// Draw the basic markings for the scale...
- if( options & HUDS_VERT ) { // Vertical scale
+ if( huds_vert(options) ) { // Vertical scale
drawOneLine( scrn_rect.left, // Bottom tick bar
scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
+ width,
scrn_rect.top);
drawOneLine( scrn_rect.left, // Top tick bar
- scrn_rect.top + scrn_rect.bottom,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom );
+ height,
+ width,
+ height );
marker_xs = scrn_rect.left;
- marker_xe = scrn_rect.left + scrn_rect.right;
+ marker_xe = width;
- if( options & HUDS_LEFT ) { // Read left, so line down right side
- drawOneLine( scrn_rect.left + scrn_rect.right,
+ if( huds_left(options) ) { // Read left, so line down right side
+ drawOneLine( width,
scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom);
-
+ width,
+ height);
+
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
- }
- if( options & HUDS_RIGHT ) { // Read right, so down left sides
+ }
+
+ if( huds_right(options) ) { // Read right, so down left sides
drawOneLine( scrn_rect.left,
scrn_rect.top,
scrn_rect.left,
- scrn_rect.top + scrn_rect.bottom);
+ height);
+
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
- }
+ }
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
- if(( options & HUDS_BOTH) == HUDS_BOTH) {
+ if( huds_both(options) ) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
- if( !(options & HUDS_NOTICKS )) { // If not no ticks...:)
+ if( !huds_noticks(options)) { // If not no ticks...:)
// Calculate x marker offsets
- for( i = (int)vmin; i <= (int)vmax; i++ ) {
+ int last = (int)vmax + 1; //FloatToInt(vmax)+1;
+ i = (int)vmin; //FloatToInt(vmin);
+ for(; i <last ; i++ ) {
+// for( i = (int)vmin; i <= (int)vmax; i++ ) {
// Calculate the location of this tick
- marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
+ marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/);
// We compute marker_ys even though we don't know if we will use
// either major or minor divisions. Simpler.
if( div_min()) { // Minor tick marks
- if( (i%div_min()) == 0) {
- if((options & HUDS_LEFT) && (options && HUDS_RIGHT)) {
+ if( !(i%(int)div_min()) ) {
+ if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs - 3, marker_ys );
drawOneLine( marker_xe + 3, marker_ys,
- scrn_rect.left + scrn_rect.right, marker_ys );
+ width, marker_ys );
}
else {
- if( options & HUDS_LEFT) {
+ if( huds_left(options) ) {
drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
}
else {
// statement.
if( div_max()) { // Major tick mark
- if( (i%div_max()) == 0 ) {
- if((options & HUDS_LEFT) && (options && HUDS_RIGHT)) {
-
+ if( !(i%(int)div_max()) ) {
+ if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs, marker_ys );
drawOneLine( marker_xe, marker_ys,
- scrn_rect.left + scrn_rect.right, marker_ys );
+ width, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
- }
+ }
- if( !(options & HUDS_NOTEXT)) {
+ if( !huds_notext(options) ) {
disp_val = i;
- sprintf( TextScale, "%d",disp_val * (int)(data_scaling() +.5));
+ lenstr = sprintf( TextScale, "%d",
+ FloatToInt(disp_val * data_scaling()/*+.5*/ ));
- if((options & HUDS_LEFT) && (options && HUDS_RIGHT)) {
- text_x = mid_scr.x - 2 - ((3 * strlen( TextScale ))>>1);
+ if( huds_left(options) && huds_right(options) ) {
+ text_x = mid_scr.x - 2 - ((3 * lenstr) >> 1);
}
else {
- if( options & HUDS_LEFT ) {
- text_x = marker_xs - 2 - 3 * strlen( TextScale);
+ if( huds_left(options) ) {
+ text_x = marker_xs - 2 - 3 * lenstr;
}
else {
- text_x = marker_xe + 10 - strlen( TextScale );
+ text_x = marker_xe + 10 - lenstr;
}
}
// Now we know where to put the text.
// have been drawn, text_x and text_y may be recycled. This is used
// with the marker start stops to produce a pointer for each side reading
- text_y = scrn_rect.top + (int)((cur_value - vmin) * factor() + .5);
+ text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
// text_x = marker_xs - scrn_rect.left;
- if( options & HUDS_RIGHT ) {
- drawOneLine(scrn_rect.left, text_y + 5,
- marker_xe, text_y);
- drawOneLine(scrn_rect.left, text_y - 5,
- marker_xe, text_y);
+ if( huds_right(options) ) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( scrn_rect.left, text_y + 5);
+ glVertex2f( marker_xe, text_y);
+ glVertex2f( scrn_rect.left, text_y - 5);
+ glEnd();
}
- if( options & HUDS_LEFT ) {
- drawOneLine(scrn_rect.left + scrn_rect.right, text_y + 5,
- marker_xs, text_y);
- drawOneLine(scrn_rect.left + scrn_rect.right, text_y - 5,
- marker_xs, text_y);
+ if( huds_left(options) ) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( width, text_y + 5);
+ glVertex2f( marker_xs, text_y);
+ glVertex2f( width, text_y - 5);
+ glEnd();
}
} // End if VERTICAL SCALE TYPE
else { // Horizontal scale by default
drawOneLine( scrn_rect.left, // left tick bar
scrn_rect.top,
scrn_rect.left,
- scrn_rect.top + scrn_rect.bottom);
+ height);
- drawOneLine( scrn_rect.left + scrn_rect.right, // right tick bar
+ drawOneLine( width, // right tick bar
scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom );
+ width,
+ height );
marker_ys = scrn_rect.top; // Starting point for
- marker_ye = scrn_rect.top + scrn_rect.bottom; // tick y location calcs
- marker_xs = scrn_rect.left + (int)((cur_value - vmin) * factor() + .5);
+ marker_ye = height; // tick y location calcs
+ marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
- if( options & HUDS_TOP ) {
+ if( huds_top(options) ) {
drawOneLine( scrn_rect.left,
scrn_rect.top,
- scrn_rect.left + scrn_rect.right,
+ width,
scrn_rect.top); // Bottom box line
-
+
marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
// Bottom arrow
- drawOneLine( marker_xs, marker_ye,
- marker_xs - scrn_rect.bottom / 4, scrn_rect.top);
- drawOneLine( marker_xs, marker_ye,
- marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
- }
- if( options & HUDS_BOTTOM) {
- drawOneLine( scrn_rect.left,
- scrn_rect.top + scrn_rect.bottom,
- scrn_rect.left + scrn_rect.right,
- scrn_rect.top + scrn_rect.bottom); // Top box line
- // Tick point adjust
- marker_ys = scrn_rect.top +
- scrn_rect.bottom - scrn_rect.bottom / 2;
- // Top arrow
- drawOneLine( marker_xs + scrn_rect.bottom / 4,
- scrn_rect.top + scrn_rect.bottom,
- marker_xs,
- marker_ys );
- drawOneLine( marker_xs - scrn_rect.bottom / 4,
- scrn_rect.top + scrn_rect.bottom,
- marker_xs ,
- marker_ys );
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( marker_xs - bottom_4, scrn_rect.top);
+ glVertex2f( marker_xs, marker_ye);
+ glVertex2f( marker_xs + bottom_4, scrn_rect.top);
+ glEnd();
}
+ if( huds_bottom(options) ) {
+ // Top box line
+ drawOneLine( scrn_rect.left, height, width, height);
+ // Tick point adjust
+ marker_ys = height - scrn_rect.bottom / 2;
+
+ // Top arrow
+ glBegin(GL_LINE_STRIP);
+ glVertex2f( marker_xs + bottom_4, height);
+ glVertex2f( marker_xs, marker_ys );
+ glVertex2f( marker_xs - bottom_4, height);
+ glEnd();
+ }
- for( i = (int)vmin; i <= (int)vmax; i++ ) {
+
+ int last = (int)vmax + 1; //FloatToInt(vmax)+1;
+ i = (int)vmin; //FloatToInt(vmin);
+ for( ; i <last ; i++ ) {
condition = true;
if( !modulo()) {
if( i < min_val()) {
}
}
if( condition ) {
- marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
+ marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/);
+// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
if( div_min()){
- if( (i%(int)div_min()) == 0 ) {
+ if( !(i%(int)div_min()) ) {
// draw in ticks only if they aren't too close to the edge.
if((( marker_xs + 5) > scrn_rect.left ) ||
- (( marker_xs - 5 )< (scrn_rect.left + scrn_rect.right))){
+ (( marker_xs - 5 )< (width))){
- if( (options & HUDS_BOTH) == HUDS_BOTH ) {
+ if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
drawOneLine( marker_xs, marker_ye + 4,
- marker_xs, scrn_rect.top + scrn_rect.bottom);
- }
+ marker_xs, height);
+ }
else {
- if( options & HUDS_TOP) {
+ if( huds_top(options) ) {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye - 4);
}
}
}
if( div_max()) {
- if( (i%(int)div_max())==0 ) {
- if(modulo()) {
- if( disp_val < 0) {
- disp_val += modulo();
- }
- else {
- disp_val = i % modulo();
- }
- }
- else {
- disp_val = i;
+ if( !(i%(int)div_max()) ) {
+ if(modulo()) {
+ if( disp_val < 0) {
+ while( disp_val < 0 ) {
+ disp_val += modulo();
+ }
+ }
+ disp_val = i % (int)modulo();
+ } else {
+ disp_val = i;
}
- sprintf( TextScale, "%d", (int)(disp_val * data_scaling() +.5));
+ lenstr = 4 * sprintf( TextScale, "%d",
+ FloatToInt(disp_val * data_scaling()/* +.5*/ ));
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
- ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
- if( (options & HUDS_BOTH) == HUDS_BOTH) {
+ ( (marker_xs + 10) < width )){
+ if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys);
drawOneLine( marker_xs, marker_ye,
- marker_xs, scrn_rect.top + scrn_rect.bottom);
+ marker_xs, height);
- if( !(options & HUDS_NOTEXT)) {
- textString ( marker_xs - 4 * strlen(TextScale),
- marker_ys + 4,
+ if( !huds_notext(options) ) {
+ textString ( marker_xs - lenstr, marker_ys + 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
- if( !(options & HUDS_NOTEXT)) {
- if( options & HUDS_TOP ) {
- textString ( marker_xs - 4 * strlen(TextScale),
- scrn_rect.top + scrn_rect.bottom - 10,
+
+ if( !huds_notext(options) ) {
+ if( huds_top(options) ) {
+ textString ( marker_xs - lenstr,
+ height - 10,
TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
- textString( marker_xs - 4 * strlen(TextScale),
- scrn_rect.top,
+ textString( marker_xs - lenstr, scrn_rect.top,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
int y,
UINT width,
UINT height,
- DBLFNPTR data_source,
- double data_scaling,
+ FLTFNPTR data_source,
+ float data_scaling,
UINT options,
bool working) :
handle ( ++instances ),
#include <stdlib.h>
#include <string.h>
#include <Aircraft/aircraft.hxx>
+#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Math/fg_random.h>
#include <Math/mat3.h>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
-
#include "hud.hxx"
+#ifdef USE_HUD_TextList
+#define textString( x , y, text, font ) TextString( font, text, x , y )
+#endif
+
//======================= Top of instr_label class =========================
instr_label ::
instr_label( int x,
int y,
UINT width,
UINT height,
- DBLFNPTR data_source,
+ FLTFNPTR data_source,
const char *label_format,
const char *pre_label_string,
const char *post_label_string,
- double scale_data,
+ float scale_data,
UINT options,
fgLabelJust justification,
int font_size,
fontSize ( font_size ),
blink ( blinking )
{
+ if( pre_str != NULL) {
+ if( post_str != NULL ) {
+ sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
+ }
+ else {
+ sprintf( format_buffer, "%s%s", pre_str, pformat );
+ }
+ }
+ else {
+ if( post_str != NULL ) {
+ sprintf( format_buffer, "%s%s", pformat, post_str );
+ }
+ } // else do nothing if both pre and post strings are nulls. Interesting.
+
}
// I put this in to make it easy to construct a class member using the current
post_str ( image.post_str ),
blink ( image.blink )
{
+ if( pre_str != NULL) {
+ if( post_str != NULL ) {
+ sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
+ }
+ else {
+ sprintf( format_buffer, "%s%s", pre_str, pformat );
+ }
+ }
+ else {
+ if( post_str != NULL ) {
+ sprintf( format_buffer, "%s%s", pformat, post_str );
+ }
+ } // else do nothing if both pre and post strings are nulls. Interesting.
+
}
instr_label & instr_label ::operator = (const instr_label & rhs )
justify = rhs.justify;
pre_str = rhs.pre_str;
post_str = rhs.post_str;
+ strcpy(format_buffer,rhs.format_buffer);
}
- return *this;
+ return *this;
}
//
void instr_label ::
draw( void ) // Required method in base class
{
- char format_buffer[80];
+// char format_buffer[80];
char label_buffer[80];
int posincr;
int lenstr;
RECT scrn_rect = get_location();
- if( pre_str != NULL) {
- if( post_str != NULL ) {
- sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
- }
- else {
- sprintf( format_buffer, "%s%s", pre_str, pformat );
- }
- }
- else {
- if( post_str != NULL ) {
- sprintf( format_buffer, "%s%s", pformat, post_str );
- }
- } // else do nothing if both pre and post strings are nulls. Interesting.
+// if( pre_str != NULL) {
+// if( post_str != NULL ) {
+// sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
+// }
+// else {
+// sprintf( format_buffer, "%s%s", pre_str, pformat );
+// }
+// }
+// else {
+// if( post_str != NULL ) {
+// sprintf( format_buffer, "%s%s", pformat, post_str );
+// }
+// } // else do nothing if both pre and post strings are nulls. Interesting.
if( data_available() ) {
- sprintf( label_buffer, format_buffer, get_value() );
+ lenstr = sprintf( label_buffer, format_buffer, get_value() );
}
else {
- sprintf( label_buffer, format_buffer );
+ lenstr = sprintf( label_buffer, format_buffer );
}
#ifdef DEBUGHUD
- fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
- fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
- fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
- fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
+ fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
+ fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
+ fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
+ fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
#endif
- lenstr = strlen( label_buffer );
+// lenstr = strlen( label_buffer );
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
posincr = - (lenstr << 8); // 0;
}
}
-
if( fontSize == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13);
#include "hud.hxx"
//====================== Top of HudLadder Class =======================
-HudLadder ::
- HudLadder( int x,
- int y,
- UINT width,
- UINT height,
- DBLFNPTR ptch_source,
- DBLFNPTR roll_source,
- double span_units,
- double major_div,
- double minor_div,
- UINT screen_hole,
- UINT lbl_pos,
- bool working) :
- dual_instr_item( x, y, width, height,
- ptch_source,
- roll_source,
- working,
- HUDS_RIGHT),
- width_units ( span_units ),
- div_units ( major_div < 0? -major_div: major_div ),
- minor_div ( minor_div ),
- label_pos ( lbl_pos ),
- scr_hole ( screen_hole ),
- vmax ( span_units/2 ),
- vmin ( -vmax )
-{
- if( !width_units ) {
- width_units = 45;
+HudLadder :: HudLadder( int x,
+ int y,
+ UINT width,
+ UINT height,
+ FLTFNPTR ptch_source,
+ FLTFNPTR roll_source,
+ float span_units,
+ float major_div,
+ float minor_div,
+ UINT screen_hole,
+ UINT lbl_pos,
+ bool working) :
+ dual_instr_item( x, y, width, height,
+ ptch_source,
+ roll_source,
+ working,
+ HUDS_RIGHT),
+ width_units ( (int)(span_units) ),
+ div_units ( (int)(major_div < 0? -major_div: major_div) ),
+ minor_div ( (int)(minor_div) ),
+ label_pos ( lbl_pos ),
+ scr_hole ( screen_hole ),
+ vmax ( span_units/2 ),
+ vmin ( -vmax )
+ {
+ if( !width_units ) {
+ width_units = 45;
+ }
+ factor = (float)get_span() / (float) width_units;
+ }
+
+HudLadder :: ~HudLadder()
+ {
}
- factor = (double)get_span() / (double) width_units;
-}
-
-HudLadder ::
- ~HudLadder()
-{
-}
-
-HudLadder ::
- HudLadder( const HudLadder & image ) :
- dual_instr_item( (dual_instr_item &) image),
- width_units ( image.width_units ),
- div_units ( image.div_units ),
- label_pos ( image.label_pos ),
- scr_hole ( image.scr_hole ),
- vmax ( image.vmax ),
- vmin ( image.vmin ),
- factor ( image.factor )
-{
-}
-HudLadder & HudLadder ::
- operator = ( const HudLadder & rhs )
-{
- if( !(this == &rhs)) {
- (dual_instr_item &)(*this) = (dual_instr_item &)rhs;
- width_units = rhs.width_units;
- div_units = rhs.div_units;
- label_pos = rhs.label_pos;
- scr_hole = rhs.scr_hole;
- vmax = rhs.vmax;
- vmin = rhs.vmin;
- factor = rhs.factor;
+
+ HudLadder ::
+ HudLadder( const HudLadder & image ) :
+ dual_instr_item( (dual_instr_item &) image),
+ width_units ( image.width_units ),
+ div_units ( image.div_units ),
+ label_pos ( image.label_pos ),
+ scr_hole ( image.scr_hole ),
+ vmax ( image.vmax ),
+ vmin ( image.vmin ),
+ factor ( image.factor )
+ {
}
- return *this;
-}
-
+HudLadder & HudLadder :: operator = ( const HudLadder & rhs )
+ {
+ if( !(this == &rhs)) {
+ (dual_instr_item &)(*this) = (dual_instr_item &)rhs;
+ width_units = rhs.width_units;
+ div_units = rhs.div_units;
+ label_pos = rhs.label_pos;
+ scr_hole = rhs.scr_hole;
+ vmax = rhs.vmax;
+ vmin = rhs.vmin;
+ factor = rhs.factor;
+ }
+ return *this;
+ }
+
//
-// Draws a climb ladder in the center of the HUD
+// Draws a climb ladder in the center of the HUD
//
+
+inline static void _strokeString(float xx, float yy, char *msg, void *font)
+{
+ int c;
+ if(*msg)
+ {
+ glTranslatef( xx, yy, 0);
+ glScalef(.075, .075, 0.0);
+ while ((c=*msg++)) {
+ glutStrokeCharacter( font, c);
+ }
+ }
+}
void HudLadder :: draw( void )
{
- double roll_value;
- double pitch_value;
- int marker_y;
- int x_ini;
- int x_end;
- int y_ini;
- int y_end;
- int new_x_ini;
- int new_x_end;
- int new_y_ini;
- int new_y_end;
- int i;
- POINT centroid = get_centroid();
- RECT box = get_location();
- int scr_min = box.top;
- int half_span = box.right >> 1;
- char TextLadder[80];
- int condition;
- int label_length;
- roll_value = current_ch2();
- GLfloat sinRoll = sin( roll_value );
- GLfloat cosRoll = cos( roll_value );
+ float roll_value;
+ float pitch_value;
+ float marker_y;
+ float x_ini;
+ float x_end;
+ float y_ini;
+ float y_end;
+
+ int i;
+ POINT centroid = get_centroid();
+ RECT box = get_location();
- pitch_value = current_ch1() * RAD_TO_DEG;
- vmin = pitch_value - (double)width_units/2.0;
- vmax = pitch_value + (double)width_units/2.0;
+ int half_span = box.right >> 1;
+ char TextLadder[80];
-// Box the target.
- drawOneLine( centroid.x - 5, centroid.y, centroid.x, centroid.y + 5);
- drawOneLine( centroid.x, centroid.y + 5, centroid.x + 5, centroid.y);
- drawOneLine( centroid.x + 5, centroid.y, centroid.x, centroid.y - 5);
- drawOneLine( centroid.x, centroid.y - 5, centroid.x - 5, centroid.y);
+ int label_length;
+ roll_value = current_ch2();
+
+ float hole = (float)((scr_hole)/2);
+
+ GLfloat mat[16];
+
+ pitch_value = current_ch1() * RAD_TO_DEG;
+ vmin = pitch_value - (float)width_units/2.0;
+ vmax = pitch_value + (float)width_units/2.0;
- for( i=(int)vmin; i<=(int)vmax; i++ ) { // Through integer pitch values...
- condition = 1;
- if( condition ) {
- marker_y = centroid.y + (int)(((double)(i - pitch_value) * factor) + .5);
- if( div_units ) {
- if( !(i % div_units )) { // At integral multiple of div
- sprintf( TextLadder, "%d", i );
- label_length = strlen( TextLadder );
- if( scr_hole == 0 ) {
- if( i ) {
- x_ini = centroid.x - half_span;
- }
- else { // Make zero point wider on left
- x_ini = centroid.x - half_span - 10;
- }
- y_ini = marker_y;
- x_end = centroid.x + half_span;
- y_end = marker_y;
- new_x_ini = centroid.x + (int)(
- (x_ini - centroid.x) * cosRoll -
- (y_ini - centroid.y) * sinRoll);
- new_y_ini = centroid.y + (int)( \
- (x_ini - centroid.x) * sinRoll + \
- (y_ini - centroid.y) * cosRoll);
- new_x_end = centroid.x + (int)( \
- (x_end - centroid.x) * cosRoll - \
- (y_end - centroid.y) * sinRoll);
- new_y_end = centroid.y + (int)( \
- (x_end - centroid.x) * sinRoll + \
- (y_end - centroid.y) * cosRoll);
- if( i >= 0 ) { // Above zero draw solid lines
- drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
- }
- else { // Below zero draw dashed lines.
- glEnable(GL_LINE_STIPPLE);
- glLineStipple( 1, 0x00FF );
- drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
- glDisable(GL_LINE_STIPPLE);
- }
- // Calculate the position of the left text and write it.
- new_x_ini = centroid.x + (int)(
- (x_ini - 8 * label_length- 4 - centroid.x) * cosRoll -
- (y_ini - 4 ) * sinRoll);
- new_y_ini = centroid.y + (int)(
- (x_ini - 8 * label_length- 4 - centroid.x) * sinRoll +
- (y_ini - 4 - centroid.y) * cosRoll);
- strokeString( new_x_ini , new_y_ini ,
- TextLadder, GLUT_STROKE_ROMAN,
- roll_value );
+ // We will do everything with glLoadMatrix :-)
+ // to avoid multiple pushing and popping matrix stack
+ glPushMatrix();
+ // glTranslatef( centroid.x, centroid.y, 0);
+ // glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
+ // glGetFloatv(GL_MODELVIEW_MATRIX, mat);
+ // this is the same as above
+ float sinx = sin(roll_value);
+ float cosx = cos(roll_value);
+ mat[0] = cosx;
+ mat[1] = sinx;
+ mat[2] = mat[3] = 0.0;
+ mat[4] = -sinx;
+ mat[5] = cosx;
+ mat[6] = mat[7] = mat[8] = mat[9];
+ mat[10] = 1.0;
+ mat[11] = 0.0;
+ mat[12] = centroid.x;
+ mat[13] = centroid.y;
+ mat[14] = 0;
+ mat[15] = 1.0;
+ glLoadMatrixf( mat );
+
+ // Draw the target spot.
+#define CENTER_DIAMOND_SIZE 5.0
+ glBegin(GL_LINE_LOOP);
+ glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
+ glVertex2f(0.0, CENTER_DIAMOND_SIZE);
+ glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
+ glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
+ glEnd();
+#if 0
+ glBegin(GL_LINES);
+ glVertex2f( -CENTER_DIAMOND_SIZE, 0);
+ glVertex2f( -(CENTER_DIAMOND_SIZE*2), 0);
+ glVertex2f(0, CENTER_DIAMOND_SIZE);
+ glVertex2f(0, (CENTER_DIAMOND_SIZE*2));
+ glVertex2f( CENTER_DIAMOND_SIZE, 0);
+ glVertex2f( (CENTER_DIAMOND_SIZE*2), 0);
+ glVertex2f(0, -CENTER_DIAMOND_SIZE);
+ glVertex2f(0, -(CENTER_DIAMOND_SIZE*2));
+ glEnd();
+#endif // 0
+#undef CENTER_DIAMOND_SIZE
- // Calculate the position of the right text and write it.
- new_x_end = centroid.x + (int)( \
- (x_end + 24 - 8 * label_length - centroid.x) * cosRoll - \
- (y_end - 4 - centroid.y) * sinRoll);
- new_y_end = centroid.y + (int)( \
- (x_end + 24 - 8 * label_length - centroid.x) * sinRoll + \
- (y_end - 4 - centroid.y) * cosRoll);
- strokeString( new_x_end, new_y_end,
- TextLadder, GLUT_STROKE_ROMAN,
- roll_value );
+ int last =FloatToInt(vmax)+1;
+ i = FloatToInt(vmin);
+ if( div_units ) {
+ if( !scr_hole ) {
+ for( ; i <last ; i++ ) {
+
+ marker_y = /*(int)*/(((float)(i - pitch_value) * factor) + .5);
+ if( !(i % div_units )) { // At integral multiple of div
+
+ label_length = sprintf( TextLadder, "%d", i );
+
+ if( i ) {
+ x_ini = -half_span;
+ } else { // Make zero point wider on left
+ x_ini = -half_span - 10;
+ }
+ x_end = half_span;
+
+ y_ini = marker_y;
+ y_end = marker_y;
+
+// printf("(%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end);
+
+ if( i >= 0 ) { // Above zero draw solid lines
+ glBegin(GL_LINES);
+ glVertex2f( x_ini, y_ini);
+ glVertex2f( x_end, y_end );
+ glEnd();
+ } else { // Below zero draw dashed lines.
+ glEnable(GL_LINE_STIPPLE);
+ glLineStipple( 1, 0x00FF );
+ glBegin(GL_LINES);
+ glVertex2f( x_ini, y_ini);
+ glVertex2f( x_end, y_end );
+ glEnd();
+ glDisable(GL_LINE_STIPPLE);
+ }
+
+ // Calculate the position of the left text and write it.
+ x_ini -= ( 8*label_length - 4);
+ y_ini -= 4;
+ _strokeString(x_ini, y_ini,
+ TextLadder, GLUT_STROKE_ROMAN );
+
+ glLoadMatrixf( mat );
+ // Calculate the position of the right text and write it.
+ x_end -= (24 - 8 * label_length);
+ y_end -= 4;
+ _strokeString(x_end, y_end,
+ TextLadder, GLUT_STROKE_ROMAN );
+ glLoadMatrixf( mat );
+ }
}
- else { // Draw ladder with space in the middle of the lines
+ }
+ else // if(scr_hole )
+ { // Draw ladder with space in the middle of the lines
+ last =FloatToInt(vmax)+1;
+ i = FloatToInt(vmin);
+ for( ; i <last ; i++ ) {
+ marker_y = /*(int)*/(((float)(i - pitch_value) * factor) + .5);
+ if( !(i % div_units )) { // At integral multiple of div
+
+ label_length = sprintf( TextLadder, "%d", i );
+
// Start by calculating the points and drawing the
// left side lines.
- if( i != 0 ) {
- x_ini = centroid.x - half_span;
- }
- else {
- x_ini = centroid.x - half_span - 10;
- }
- y_ini = marker_y;
- x_end = centroid.x - half_span + scr_hole/2;
- y_end = marker_y;
-
- new_x_end = centroid.x+ (int)( \
- (x_end - centroid.x) * cosRoll -\
- (y_end - centroid.y) * sinRoll);
- new_y_end = centroid.y+ (int)( \
- (x_end - centroid.x) * sinRoll +\
- (y_end - centroid.y) * cosRoll);
- new_x_ini = centroid.x + (int)( \
- (x_ini - centroid.x) * cosRoll -\
- (y_ini - centroid.y) * sinRoll);
- new_y_ini = centroid.y + (int)( \
- (x_ini - centroid.x) * sinRoll +\
- (y_ini - centroid.y) * cosRoll);
+ if( i != 0 ) {
+ x_ini = -half_span;
+ } else {
+ x_ini = -half_span - 10;
+ }
+ x_end = -half_span + hole;
+
+ y_ini = marker_y;
+ y_end = marker_y;
+
+// printf("half_span(%d) scr_hole(%d)\n", half_span, scr_hole);
+// printf("x_end(%f) %f\n",x_end,(float)(-half_span + scr_hole/2));
+// printf("L: (%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end);
+
+ if( i >= 0 ) { // Above zero draw solid lines
+ glBegin(GL_LINES);
+ glVertex2f( x_ini, y_ini);
+ glVertex2f( x_end, y_end );
+ glEnd();
+ } else { // Below zero draw dashed lines.
+ glEnable(GL_LINE_STIPPLE);
+ glLineStipple( 1, 0x00FF );
+ glBegin(GL_LINES);
+ glVertex2f( x_ini, y_ini);
+ glVertex2f( x_end, y_end );
+ glEnd();
+ glDisable(GL_LINE_STIPPLE);
+ }
+
+ // Now calculate the location of the left side label using
+ // the previously calculated start of the left side line.
+
+ x_ini -= (label_length + 32);
+ if( i < 0) {
+ x_ini -= 8;
+ } else {
+ if( i == 0 ) {
+ x_ini += 15; //20;
+ }
+ }
+ y_ini -= 4;
- if( i >= 0 )
- {
- drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
- }
- else {
- glEnable(GL_LINE_STIPPLE);
- glLineStipple( 1, 0x00FF );
- drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
- glDisable(GL_LINE_STIPPLE);
- }
- // Now calculate the location of the left side label using
- // the previously calculated start of the left side line.
-
- x_ini = x_ini - (label_length + 32 + centroid.x);
- if( i < 0) {
- x_ini -= 8;
- }
- else {
- if( i == 0 ) {
- x_ini += 20;
+ _strokeString(x_ini, y_ini,
+ TextLadder, GLUT_STROKE_MONO_ROMAN );
+ glLoadMatrixf( mat );
+
+ // Now calculate and draw the right side line location
+ x_ini = half_span - hole;
+ y_ini = marker_y;
+ if( i != 0 ) {
+ x_end = half_span;
+ } else {
+ x_end = half_span + 10;
+ }
+ y_end = marker_y;
+
+// printf("R: (%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end);
+
+ if( i >= 0 ) { // Above zero draw solid lines
+ glBegin(GL_LINES);
+ glVertex2f( x_ini, y_ini);
+ glVertex2f( x_end, y_end );
+ glEnd();
+ } else { // Below zero draw dashed lines.
+ glEnable(GL_LINE_STIPPLE);
+ glLineStipple( 1, 0x00FF );
+ glBegin(GL_LINES);
+ glVertex2f( x_ini, y_ini);
+ glVertex2f( x_end, y_end );
+ glEnd();
+ glDisable(GL_LINE_STIPPLE);
+ }
+
+ // Calculate the location and draw the right side label
+ // using the end of the line as previously calculated.
+ x_end -= (label_length - 24);
+
+ if( i <= 0 ) {
+ x_end -= 8;
+ } // else if( i==0)
+// {
+// x_end -=4;
+// }
+
+ y_end = marker_y - 4;
+ _strokeString(x_end, y_end,
+ TextLadder, GLUT_STROKE_MONO_ROMAN );
+ glLoadMatrixf( mat );
}
- }
- y_ini = y_ini - ( 4 + centroid.y);
-
- new_x_ini = centroid.x + (int)(x_ini * cosRoll - y_ini * sinRoll);
- new_y_ini = centroid.y + (int)(x_ini * sinRoll + y_ini * cosRoll);
- strokeString( new_x_ini , new_y_ini ,
- TextLadder, GLUT_STROKE_MONO_ROMAN,
- roll_value );
-
- // Now calculate and draw the right side line location
- x_ini = centroid.x + half_span - scr_hole/2;
- y_ini = marker_y;
- if( i != 0 ) {
- x_end = centroid.x + half_span;
- }
- else {
- x_end = centroid.x + half_span + 10;
- }
- y_end = marker_y;
-
- new_x_ini = centroid.x + (int)( \
- (x_ini-centroid.x)*cosRoll -\
- (y_ini-centroid.y)*sinRoll);
- new_y_ini = centroid.y + (int)( \
- (x_ini-centroid.x)*sinRoll +\
- (y_ini-centroid.y)*cosRoll);
- new_x_end = centroid.x + (int)( \
- (x_end-centroid.x)*cosRoll -\
- (y_end-centroid.y)*sinRoll);
- new_y_end = centroid.y + (int)( \
- (x_end-centroid.x)*sinRoll +\
- (y_end-centroid.y)*cosRoll);
-
- if( i >= 0 )
- {
- drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
- }
- else
- {
- glEnable(GL_LINE_STIPPLE);
- glLineStipple( 1, 0x00FF );
- drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
- glDisable(GL_LINE_STIPPLE);
- }
-
- // Calculate the location and draw the right side label
- // using the end of the line as previously calculated.
- x_end -= centroid.x + label_length - 24;
- if( i < 0 ) {
- x_end -= 8;
- }
- y_end = marker_y - ( 4 + centroid.y);
- new_x_end = centroid.x + (int)( (GLfloat)x_end * cosRoll -
- (GLfloat)y_end * sinRoll);
- new_y_end = centroid.y + (int)( (GLfloat)x_end * sinRoll +
- (GLfloat)y_end * cosRoll);
- strokeString( new_x_end, new_y_end,
- TextLadder, GLUT_STROKE_MONO_ROMAN,
- roll_value );
}
- }
}
- }
}
+ glPopMatrix();
}
int y,
UINT width,
UINT height,
- DBLFNPTR load_fn,
+ FLTFNPTR load_fn,
UINT options,
- double show_range,
- double maxValue,
- double minValue,
- double disp_scale,
+ float show_range,
+ float maxValue,
+ float minValue,
+ float disp_scale,
UINT major_divs,
UINT minor_divs,
UINT rollover,
{
int temp;
- scale_factor = (double)get_span() / range_shown;
+ scale_factor = (float)get_span() / range_shown;
if( show_range < 0 ) {
range_shown = -range_shown;
}
- temp = (Maximum_value - Minimum_value) / 100;
+ temp = FloatToInt(Maximum_value - Minimum_value) / 100;
if( range_shown < temp ) {
range_shown = temp;
}
int y,
UINT width,
UINT height,
- DBLFNPTR chn1_source,
- DBLFNPTR chn2_source,
- double maxBankAngle,
- double maxSlipAngle,
+ FLTFNPTR chn1_source,
+ FLTFNPTR chn2_source,
+ float maxBankAngle,
+ float maxSlipAngle,
UINT gap_width,
bool working ) :
dual_instr_item( x, y, width, height,
chn2_source,
working,
HUDS_TOP),
- BankLimit (maxBankAngle),
- SlewLimit (maxSlipAngle),
+ BankLimit ((int)(maxBankAngle)),
+ SlewLimit ((int)(maxSlipAngle)),
scr_hole (gap_width )
{
}
}
//
-// Draws a Turn Bank Indicator on the screen
+// Draws a Turn Bank Indicator on the screen
//
void fgTBI_instr :: draw( void )
{
- int x_inc1, y_inc1;
- int x_inc2, y_inc2;
- int x_t_inc1, y_t_inc1;
-
- int d_bottom_x, d_bottom_y;
- int d_right_x, d_right_y;
- int d_top_x, d_top_y;
- int d_left_x, d_left_y;
-
- int inc_b_x, inc_b_y;
- int inc_r_x, inc_r_y;
- int inc_t_x, inc_t_y;
- int inc_l_x, inc_l_y;
- RECT My_box = get_location();
- POINT centroid = get_centroid();
- int tee_height = My_box.bottom;
-
-// struct fgFLIGHT *f = ¤t_aircraft.flight;
- double sin_bank, cos_bank;
- double bank_angle, sideslip_angle;
- double ss_const; // sideslip angle pixels per rad
-
- bank_angle = current_ch2(); // Roll limit +/- 30 degrees
- if( bank_angle < -FG_PI_2/3 ) {
- bank_angle = -FG_PI_2/3;
- }
- else
- if( bank_angle > FG_PI_2/3 ) {
- bank_angle = FG_PI_2/3;
- }
- sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
- if( sideslip_angle < -FG_PI/9 ) {
- sideslip_angle = -FG_PI/9;
- }
- else
- if( sideslip_angle > FG_PI/9 ) {
- sideslip_angle = FG_PI/9;
- }
-
- // sin_bank = sin( FG_2PI-FG_Phi );
- // cos_bank = cos( FG_2PI-FG_Phi );
- sin_bank = sin(FG_2PI-bank_angle);
- cos_bank = cos(FG_2PI-bank_angle);
-
- x_inc1 = (int)(get_span() * cos_bank);
- y_inc1 = (int)(get_span() * sin_bank);
- x_inc2 = (int)(scr_hole * cos_bank);
- y_inc2 = (int)(scr_hole * sin_bank);
-
- x_t_inc1 = (int)(tee_height * sin_bank);
- y_t_inc1 = (int)(tee_height * cos_bank);
-
- d_bottom_x = 0;
- d_bottom_y = (int)(-scr_hole);
- d_right_x = (int)(scr_hole);
- d_right_y = 0;
- d_top_x = 0;
- d_top_y = (int)(scr_hole);
- d_left_x = (int)(-scr_hole);
- d_left_y = 0;
-
- ss_const = (get_span()*2)/(FG_2PI/9); // width represents 40 degrees
-
- d_bottom_x += (int)(sideslip_angle*ss_const);
- d_right_x += (int)(sideslip_angle*ss_const);
- d_left_x += (int)(sideslip_angle*ss_const);
- d_top_x += (int)(sideslip_angle*ss_const);
-
- inc_b_x = (int)(d_bottom_x*cos_bank-d_bottom_y*sin_bank);
- inc_b_y = (int)(d_bottom_x*sin_bank+d_bottom_y*cos_bank);
- inc_r_x = (int)(d_right_x*cos_bank-d_right_y*sin_bank);
- inc_r_y = (int)(d_right_x*sin_bank+d_right_y*cos_bank);
- inc_t_x = (int)(d_top_x*cos_bank-d_top_y*sin_bank);
- inc_t_y = (int)(d_top_x*sin_bank+d_top_y*cos_bank);
- inc_l_x = (int)(d_left_x*cos_bank-d_left_y*sin_bank);
- inc_l_y = (int)(d_left_x*sin_bank+d_left_y*cos_bank);
-
- if( scr_hole == 0 )
- {
- drawOneLine( centroid.x - x_inc1, centroid.y - y_inc1, \
- centroid.x + x_inc1, centroid.y + y_inc1 );
- }
- else
- {
- drawOneLine( centroid.x - x_inc1, centroid.y - y_inc1, \
- centroid.x - x_inc2, centroid.y - y_inc2 );
- drawOneLine( centroid.x + x_inc2, centroid.y + y_inc2, \
- centroid.x + x_inc1, centroid.y + y_inc1 );
- }
-
- // draw teemarks
- drawOneLine( centroid.x + x_inc2, \
- centroid.y + y_inc2, \
- centroid.x + x_inc2 + x_t_inc1, \
- centroid.y + y_inc2 - y_t_inc1 );
- drawOneLine( centroid.x - x_inc2, \
- centroid.y - y_inc2, \
- centroid.x - x_inc2 + x_t_inc1, \
- centroid.y - y_inc2 - y_t_inc1 );
-
- // draw sideslip diamond (it is not yet positioned correctly )
- drawOneLine( centroid.x + inc_b_x, \
- centroid.y + inc_b_y, \
- centroid.x + inc_r_x, \
- centroid.y + inc_r_y );
- drawOneLine( centroid.x + inc_r_x, \
- centroid.y + inc_r_y, \
- centroid.x + inc_t_x, \
- centroid.y + inc_t_y );
- drawOneLine( centroid.x + inc_t_x, \
- centroid.y + inc_t_y, \
- centroid.x + inc_l_x, \
- centroid.y + inc_l_y );
- drawOneLine( centroid.x + inc_l_x, \
- centroid.y + inc_l_y, \
- centroid.x + inc_b_x, \
- centroid.y + inc_b_y );
-
+ float bank_angle, sideslip_angle;
+ float ss_const; // sideslip angle pixels per rad
+ float cen_x, cen_y, bank, fspan, tee, hole;
+
+ int span = get_span();
+
+ float zero = 0.0;
+
+ RECT My_box = get_location();
+ POINT centroid = get_centroid();
+ int tee_height = My_box.bottom;
+
+ bank_angle = current_ch2(); // Roll limit +/- 30 degrees
+
+ if( bank_angle < -FG_PI_2/3 ) {
+ bank_angle = -FG_PI_2/3;
+ } else if( bank_angle > FG_PI_2/3 ) {
+ bank_angle = FG_PI_2/3;
+ }
+
+ sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
+
+ if( sideslip_angle < -FG_PI/9 ) {
+ sideslip_angle = -FG_PI/9;
+ } else if( sideslip_angle > FG_PI/9 ) {
+ sideslip_angle = FG_PI/9;
+ }
+
+ cen_x = centroid.x;
+ cen_y = centroid.y;
+ bank = bank_angle * RAD_TO_DEG;
+ tee = -tee_height;
+ fspan = span;
+ hole = scr_hole;
+ ss_const = 2 * sideslip_angle * fspan/(FG_2PI/9); // width represents 40 degrees
+
+// printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
+// printf("ss_const: %f hole: %f\n", ss_const, hole);
+
+ glPushMatrix();
+ glTranslatef(cen_x, cen_y, zero);
+ glRotatef(-bank, zero, zero, 1.0);
+
+ glBegin(GL_LINES);
+
+ if( !scr_hole )
+ {
+ glVertex2f( -fspan, zero );
+ glVertex2f( fspan, zero );
+ } else {
+ glVertex2f( -fspan, zero );
+ glVertex2f( -hole, zero );
+ glVertex2f( hole, zero );
+ glVertex2f( fspan, zero );
+ }
+ // draw teemarks
+ glVertex2f( hole, zero );
+ glVertex2f( hole, tee );
+ glVertex2f( -hole, zero );
+ glVertex2f( -hole, tee );
+
+ glEnd();
+
+ glBegin(GL_LINE_LOOP);
+ glVertex2f( ss_const, -hole);
+ glVertex2f( ss_const + hole, zero);
+ glVertex2f( ss_const, hole);
+ glVertex2f( ss_const - hole, zero);
+ glEnd();
+
+ glPopMatrix();
}
# include <config.h>
#endif
-#ifdef FG_MATH_EXCEPTION_CLASH
-# include <math.h>
-#endif
-
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
static GLfloat Wings[] = {
-1.25, -28.125, 1.255, -28.125, 1.255, 28.125, -1.25, 28.125};
-
+
static GLfloat Elevator[] = {
3.0, -10.9375, 4.5, -10.9375, 4.5, 10.9375, 3.0, 10.9375};
-
+
static GLfloat Rudder[] = {
2.0, -0.45, 10.625, -0.45, 10.625, 0.55, 2.0, 0.55};
char line[256];
GLint test;
GLubyte *tex = new GLubyte[262144];
-
+
if(OurPanel) {
- FG_LOG( FG_GENERAL, FG_ALERT, "Error: only one Panel allowed" );
- exit(-1);
+ FG_LOG( FG_GENERAL, FG_ALERT, "Error: only one Panel allowed" );
+ exit(-1);
}
-
+
OurPanel = this;
-
+
Xzoom = (float)((float)(current_view.get_winWidth())/1024);
Yzoom = (float)((float)(current_view.get_winHeight())/768);
-
+
test_instr[3] = new FGTexInstrument(144.375, 166.875, 4, 32, 3, 30, 15.0,
- 260.0, -20.0, 360, 65, 193, 0);
+ 260.0, -20.0, 360, 65, 193, 0);
test_instr[4] = new FGTexInstrument(358, 52, 4, 30, 3, 30, -3.0, 3.0, 100,
- 440, 66.15, 66, 2);
+ 440, 66.15, 66, 2);
test_instr[5] = new FGTexInstrument(357.5, 167, 5, 25, 4, 30, 0, 10000, 0,
- 360, 194, 191, 1);
+ 360, 194, 191, 1);
test_instr[6] = new FGTexInstrument(357.5, 167, 5, 32, 3, 30, 0, 3000, 0,
- 1080, 194, 191, 1);
+ 1080, 194, 191, 1);
test_instr[0] = new FGHorizon(251, 166.75);
test_instr[1] = new FGTurnCoordinator(143.75, 51.75);
//test_instr[2] = new FGRpmGauge(462.5, 133);
test_instr[2] = new FGTexInstrument(462.5, 133, 10, 20, 5.5, 60, 0.0, 1.0,
- -67, 180, 174, 83, 3);
-
+ -67, 180, 174, 83, 3);
+
// FontList = glGenLists (256);
// glListBase(FontList);
// InitLists();
-
+
#ifdef GL_VERSION_1_1
xglGenTextures(2, panel_tex_id);
xglBindTexture(GL_TEXTURE_2D, panel_tex_id[1]);
#else
# error port me
#endif
-
+
xglMatrixMode(GL_PROJECTION);
xglPushMatrix();
xglLoadIdentity();
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
+
// load in the texture data
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 256);
tpath.append( "Textures/gauges.rgb" );
if((img = read_rgb_texture( (char *)tpath.c_str(), &img_width, &img_height ))==NULL){
}
-
+
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 256);
tpath.set( current_options.get_fg_root() );
tpath.append( "Textures/gauges2.rgb" );
if((imag = read_rgb_texture( (char *)tpath.c_str(), &imag_width, &imag_height ))==NULL){
}
-
+
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 1024);
-
+
tpath.set( current_options.get_fg_root() );
tpath.append( "Textures/Fullone.rgb" );
if ((background = read_rgb_texture( (char *)tpath.c_str(), &width, &height ))==NULL ){
}
-
+
// for(y=0;y<256;y++){
- // for(x=0;x<256;x++){
- // tex[(y+x*256)*3] = imag[(y+x*256)*3];
- // tex[(y+x*256)*3 + 1] = imag[(y+x*256)*3 + 1];
- // tex[(y+x*256)*3 + 2] = imag[(y+x*256)*3 + 2];
- // tex[(y+x*256)*3 + 3] = (imag[(y+x*256)*3 + 1] + imag[(y+x*256)*3 + 2] // + imag[(y+x*256)*3 + 0])/3;
- //
- // if((imag[(y+x*256)*3] < 150) && (imag[(y+x*256)*3 +1] < 150) && // (imag[(y+x*256)*3 + 2] < 150) ){
+ // for(x=0;x<256;x++){
+ // tex[(y+x*256)*3] = imag[(y+x*256)*3];
+ // tex[(y+x*256)*3 + 1] = imag[(y+x*256)*3 + 1];
+ // tex[(y+x*256)*3 + 2] = imag[(y+x*256)*3 + 2];
+ // tex[(y+x*256)*3 + 3] = (imag[(y+x*256)*3 + 1] + imag[(y+x*256)*3 + 2] // + imag[(y+x*256)*3 + 0])/3;
+ //
+ // if((imag[(y+x*256)*3] < 150) && (imag[(y+x*256)*3 +1] < 150) && // (imag[(y+x*256)*3 + 2] < 150) ){
// tex[(y+x*256)*3 + 3] = 0x0;
// }
// else{
// tex[(y+x*256)*3 + 3] = 0xff;
// }
- // }
+ // }
// }
-
+
xglPixelZoom(Xzoom, Yzoom);
xglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 1024);
xglPixelZoom(Xzoom, Yzoom);
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 256);
xglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, imag);
-
+
#ifdef GL_VERSION_1_1
xglBindTexture(GL_TEXTURE_2D, panel_tex_id[0]);
#elif GL_EXT_texture_object
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
xglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)(img));
-
+
xglMatrixMode(GL_MODELVIEW);
xglPopMatrix();
}
xglRasterPos2i(x, y);
xglPixelZoom(Xzoom, Yzoom);
xglDrawPixels(finx - x, finy - y, GL_RGB, GL_UNSIGNED_BYTE,
- (GLvoid *)(background));
-
+ (GLvoid *)(background));
+
// restore original buffer state
xglDrawBuffer( (GLenum)buffer );
xglEnable(GL_DEPTH_TEST);
}
void FGPanel::Update ( void ) {
-
+
float alpha;
double pitch;
double roll;
// static bool beech_drawn = false;
// char *test = "ALM 100";
-
+
var[0] = get_speed() /* * 1.4 */; // We have to multiply the airspeed by a
// factor, to simulate flying a Bonanza
var[1] = get_altitude();
var[2] = get_climb_rate() / 1000.0;
var[3] = get_throttleval();
-
+
xglMatrixMode(GL_PROJECTION);
xglPushMatrix();
xglLoadIdentity();
xglEnable(GL_LIGHTING);
xglEnable(GL_TEXTURE_2D);
xglDisable(GL_BLEND);
-
+
xglMatrixMode(GL_MODELVIEW);
xglPopMatrix();
xglPushMatrix();
-
+
xglDisable(GL_LIGHTING);
test_instr[3]->Render();
test_instr[4]->Render();
test_instr[1]->Render();
test_instr[2]->Render();
-
+
// DrawBeechcraftLogo(230, 235, 30, 10);
// DrawScale(144.375, 166.875, 38, 41.0, 18, 340, 44, 2.0, 1.0, 1.0, 1.0);
xglEnable(GL_LIGHTING);
-
+
test_instr[0]->Render();
// horizon - Let's draw an artificial horizon using both texture mapping and
// primitive drawing
-
+
void FGHorizon::Render(void){
double pitch;
double roll;
pitch = get_pitch() * RAD_TO_DEG;
if(pitch > 45)
- pitch = 45;
+ pitch = 45;
if(pitch < -45)
- pitch = -45;
+ pitch = -45;
roll = get_roll() * RAD_TO_DEG;
xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
xglMatrixMode(GL_TEXTURE);
xglPushMatrix();
-
+
// computations for the non-textured parts of the AH
shifted = -((pitch / 10) * 7.0588235);
-
+
if(shifted > (bottom - radius)){
- theta = (180 - (acos((bottom - shifted) / radius)*RAD_TO_DEG));
- n = (int)(theta / epsi) - 1;
- n1 = n;
- n2 = (180 - n1) + 2;
- dn = n2 - n1;
- rot = (int)(roll / epsi);
- n1 += rot + 45;
- n2 += rot + 45;
+ theta = (180 - (acos((bottom - shifted) / radius)*RAD_TO_DEG));
+ n = (int)(theta / epsi) - 1;
+ n1 = n;
+ n2 = (180 - n1) + 2;
+ dn = n2 - n1;
+ rot = (int)(roll / epsi);
+ n1 += rot + 45;
+ n2 += rot + 45;
}
if(shifted < (-top + radius)){
- theta = ((acos((-top - shifted) / radius)*RAD_TO_DEG));
- n = (int)(theta / epsi) + 1;
- n1 = n;
- n2 = (180 - n1) + 2;
- dn = n2 - n1;
- rot = (int)(roll / epsi);
- n1 += rot - 45;
- n2 += rot - 45;
- if(n1 < 0){ n1 += 180; n2 +=180;}
+ theta = ((acos((-top - shifted) / radius)*RAD_TO_DEG));
+ n = (int)(theta / epsi) + 1;
+ n1 = n;
+ n2 = (180 - n1) + 2;
+ dn = n2 - n1;
+ rot = (int)(roll / epsi);
+ n1 += rot - 45;
+ n2 += rot - 45;
+ if(n1 < 0){ n1 += 180; n2 +=180;}
}
// end of computations
-
+
light_position[0] = 0.0;
light_position[1] = 0.0;
light_position[2] = 1.5;
xglLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
xglLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
xglLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, direction);
-
+
#ifdef GL_VERSION_1_1
xglBindTexture(GL_TEXTURE_2D, panel_tex_id[1]);
#elif GL_EXT_texture_object
#else
# error port me
#endif
-
+
xglLoadIdentity();
xglTranslatef(0.0, ((pitch / 10) * 0.046875), 0.0);
xglTranslatef((texXPos/256), (texYPos/256), 0.0);
xglRotatef(-roll, 0.0, 0.0, 1.0);
xglScalef(1.7, 1.7, 0.0);
-
+
// the following loop draws the textured part of the AH
xglMaterialf(GL_FRONT, GL_SHININESS, 85.0);
xglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material4);
xglMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material5);
xglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material3);
-
+
xglMatrixMode(GL_MODELVIEW);
xglBegin(GL_TRIANGLES);
for(i=45;i<225;i++){
- xglTexCoord2f(0.0, 0.0);
- xglNormal3f(0.0, 0.0, 0.6);
- xglVertex3f(0.0, 0.0, 0.0);
- xglTexCoord2f(texCoord[i % 180][0], texCoord[i % 180][1]);
- xglNormal3f(normals[i % 180][0], normals[i % 180][1], 0.6);
- xglVertex3f(vertices[i % 180][0], vertices[i % 180][1], 0.0);
- n = (i + 1) % 180;
- xglTexCoord2f(texCoord[n][0], texCoord[n][1]);
- xglNormal3f(normals[n][0], normals[n][1], 0.6);
- xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
+ xglTexCoord2f(0.0, 0.0);
+ xglNormal3f(0.0, 0.0, 0.6);
+ xglVertex3f(0.0, 0.0, 0.0);
+ xglTexCoord2f(texCoord[i % 180][0], texCoord[i % 180][1]);
+ xglNormal3f(normals[i % 180][0], normals[i % 180][1], 0.6);
+ xglVertex3f(vertices[i % 180][0], vertices[i % 180][1], 0.0);
+ n = (i + 1) % 180;
+ xglTexCoord2f(texCoord[n][0], texCoord[n][1]);
+ xglNormal3f(normals[n][0], normals[n][1], 0.6);
+ xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
}
xglEnd();
-
- if((shifted > (bottom - radius)) && (n1 < 1000) && (n1 > 0)){
- a = sin(theta * DEG_TO_RAD) * sin(theta * DEG_TO_RAD);
- light_ambient2[0] = a;
- light_ambient2[1] = a;
- light_ambient2[2] = a;
-
- xglLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient2);
- xglLightfv(GL_LIGHT1, GL_DIFFUSE, light_ambient2);
- xglLightfv(GL_LIGHT1, GL_SPECULAR, light_ambient2);
+ if((shifted > (bottom - radius)) && (n1 < 1000) && (n1 > 0)){
- xglBegin(GL_TRIANGLES);
-
- tmp1 = n1; tmp2 = n2;
+ a = sin(theta * DEG_TO_RAD) * sin(theta * DEG_TO_RAD);
+ light_ambient2[0] = a;
+ light_ambient2[1] = a;
+ light_ambient2[2] = a;
- for(i = tmp1; i < tmp2 + 1; i++){
- n = i % 180;
- xglNormal3f(0.0, 0.0, 1.5);
- xglTexCoord2f((56 / 256), (140 / 256));
- xglVertex3f(((vertices[n1 % 180][0] + vertices[n2 % 180][0]) / 2),
- ((vertices[n1 % 180][1] + vertices[n2 % 180][1]) / 2),
- 0.0);
-
- xglTexCoord2f((57 / 256), (139 / 256));
- xglNormal3f(normals[n][0], normals[n][1], normals[n][3]);
- xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
-
- n = (i + 1) % 180;
- xglTexCoord2f((57 / 256), (139 / 256));
- xglNormal3f(normals[n][0], normals[n][1], normals[n][3]);
- xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
- }
- xglEnd();
- }
+ xglLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient2);
+ xglLightfv(GL_LIGHT1, GL_DIFFUSE, light_ambient2);
+ xglLightfv(GL_LIGHT1, GL_SPECULAR, light_ambient2);
+
+ xglBegin(GL_TRIANGLES);
+
+ tmp1 = n1; tmp2 = n2;
+
+ for(i = tmp1; i < tmp2 + 1; i++){
+ n = i % 180;
+ xglNormal3f(0.0, 0.0, 1.5);
+ xglTexCoord2f((56 / 256), (140 / 256));
+ xglVertex3f(((vertices[n1 % 180][0] + vertices[n2 % 180][0]) / 2), ((vertices[n1 % 180][1] + vertices[n2 % 180][1]) / 2), 0.0);
+
+ xglTexCoord2f((57 / 256), (139 / 256));
+ xglNormal3f(normals[n][0], normals[n][1], normals[n][3]);
+ xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
+ n = (i + 1) % 180;
+ xglTexCoord2f((57 / 256), (139 / 256));
+ xglNormal3f(normals[n][0], normals[n][1], normals[n][3]);
+ xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
+ }
+ xglEnd();
+ }
+
if((shifted < (-top + radius)) && (n1 < 1000) && (n1 > 0)){
- a = sin(theta * DEG_TO_RAD) * sin(theta * DEG_TO_RAD);
- light_ambient2[0] = a;
- light_ambient2[1] = a;
- light_ambient2[2] = a;
-
- xglLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient2);
- xglLightfv(GL_LIGHT1, GL_DIFFUSE, light_ambient2);
- xglLightfv(GL_LIGHT1, GL_SPECULAR, light_ambient2);
- xglMaterialf(GL_FRONT, GL_SHININESS, a * 85);
- xglBegin(GL_TRIANGLES);
- tmp1 = n1; tmp2 = n2;
- for(i = tmp1; i <= tmp2; i++){
- n = i % 180;
- xglNormal3f(0.0, 0.0, 1.5);
- xglTexCoord2f((73 / 256), (237 / 256));
- xglVertex3f(((vertices[n1 % 180][0] + vertices[n2 % 180][0]) / 2),
- ((vertices[n1 % 180][1] + vertices[n2 % 180][1]) / 2),
- 0.0);
-
- xglTexCoord2f((73 / 256), (236 / 256));
- xglNormal3f(normals[n][0], normals[n][1], normals[n][2]);
- xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
-
- n = (i + 1) % 180;
- xglTexCoord2f((73 / 256), (236 / 256));
- xglNormal3f(normals[n][0], normals[n][1], normals[n][2]);
- xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
- }
- xglEnd();
+ a = sin(theta * DEG_TO_RAD) * sin(theta * DEG_TO_RAD);
+ light_ambient2[0] = a;
+ light_ambient2[1] = a;
+ light_ambient2[2] = a;
+
+ xglLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient2);
+ xglLightfv(GL_LIGHT1, GL_DIFFUSE, light_ambient2);
+ xglLightfv(GL_LIGHT1, GL_SPECULAR, light_ambient2);
+ xglMaterialf(GL_FRONT, GL_SHININESS, a * 85);
+ xglBegin(GL_TRIANGLES);
+ tmp1 = n1; tmp2 = n2;
+ for(i = tmp1; i <= tmp2; i++){
+ n = i % 180;
+ xglNormal3f(0.0, 0.0, 1.5);
+ xglTexCoord2f((73 / 256), (237 / 256));
+ xglVertex3f(((vertices[n1 % 180][0] + vertices[n2 % 180][0]) / 2), ((vertices[n1 % 180][1] + vertices[n2 % 180][1]) / 2), 0.0);
+
+ xglTexCoord2f((73 / 256), (236 / 256));
+ xglNormal3f(normals[n][0], normals[n][1], normals[n][2]);
+ xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
+
+ n = (i + 1) % 180;
+ xglTexCoord2f((73 / 256), (236 / 256));
+ xglNormal3f(normals[n][0], normals[n][1], normals[n][2]);
+ xglVertex3f(vertices[n][0], vertices[n][1], 0.0);
+ }
+ xglEnd();
}
// Now we will have to draw the small triangle indicating the roll value
-
+
xglDisable(GL_LIGHTING);
xglDisable(GL_TEXTURE_2D);
xglEnd();
xglLoadIdentity();
-
+
xglBegin(GL_POLYGON);
xglColor3f(0.2109375, 0.23046875, 0.203125);
xglVertex2f(275.625, 138.0);
xglVertex2f(226.875, 138.0);
xglVertex2f(275.625, 138.0);
xglEnd();
-
+
xglLoadIdentity();
xglMatrixMode(GL_TEXTURE);
bottom = 36.5;
top = 36.5;
int n;
-
+
float step = (360*DEG_TO_RAD)/180;
-
+
for(n=0;n<180;n++){
- vertices[n][0] = cos(n * step) * radius;
- vertices[n][1] = sin(n * step) * radius;
- texCoord[n][0] = (cos(n * step) * radius)/256;
- texCoord[n][1] = (sin(n * step) * radius)/256;
- normals[n][0] = cos(n * step) * radius + sin(n * step);
- normals[n][1] = sin(n * step) * radius + cos(n * step);
- normals[n][2] = 0.0;
+ vertices[n][0] = cos(n * step) * radius;
+ vertices[n][1] = sin(n * step) * radius;
+ texCoord[n][0] = (cos(n * step) * radius)/256;
+ texCoord[n][1] = (sin(n * step) * radius)/256;
+ normals[n][0] = cos(n * step) * radius + sin(n * step);
+ normals[n][1] = sin(n * step) * radius + cos(n * step);
+ normals[n][2] = 0.0;
}
}
double speed;
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vertices);
-
+
alpha=((((float)((var[variable]) - (value1))) /
- (value2 - value1))* (alpha2 - alpha1) + alpha1);
+ (value2 - value1))* (alpha2 - alpha1) + alpha1);
if (alpha < alpha1)
- alpha = alpha1;
+ alpha = alpha1;
if (alpha > alpha2)
- alpha = alpha2;
+ alpha = alpha2;
xglMatrixMode(GL_MODELVIEW);
xglPushMatrix();
xglLoadIdentity();
int n;
float a;
float ififth;
-
+
xglEnable(GL_TEXTURE_2D);
xglEnable(GL_TEXTURE_GEN_S);
xglEnable(GL_TEXTURE_GEN_T);
xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
xglMatrixMode(GL_TEXTURE);
xglLoadIdentity();
-
+
#ifdef GL_VERSION_1_1
xglBindTexture(GL_TEXTURE_2D, panel_tex_id[Texid]);
#elif GL_EXT_texture_object
#else
# error port me
#endif
-
+
xglMatrixMode(GL_TEXTURE);
xglLoadIdentity();
xglTranslatef(-((float)((XPos/0.625)/256)), -((float)((YPos/0.625)/256)), 0.0);
xglTranslatef(texXPos/256 , texYPos/256, 0.0);
xglScalef(0.00625, 0.00625, 1.0);
-
+
xglBegin(GL_POLYGON);
- for(n=0;n<NumVerti;n += 2){
- xglVertex2f(array[n] * ScaleFactor, array[n + 1] * ScaleFactor);
+ for(n=0;n<NumVerti;n += 2){
+ xglVertex2f(array[n] * ScaleFactor, array[n + 1] * ScaleFactor);
}
xglEnd();
-
+
xglLoadIdentity();
xglMatrixMode(GL_MODELVIEW);
xglPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
xglDisable(GL_TEXTURE_2D);
xglDisable(GL_TEXTURE_GEN_S);
xglDisable(GL_TEXTURE_GEN_T);
-
+
}
// CreatePointer - calculate the vertices of a pointer
float alpha;
float alphastep;
float r = radius;
-
+
vertices[0] = 0;
vertices[1] = length;
vertices[2] = -(width/2);
vertices[3] = length - ((width/2)/(tan(angle*DEG_TO_RAD/2)));
vertices[4] = -(width/2);
vertices[5] = cos(asin((width/2)/r))*r;
-
+
alphastep = (asin((width/2)/r)+asin((width/2)/r))/5;
alpha = asin(-(width/2)/r);
-
+
for(i=0;i<5;i++){
- alpha += alphastep;
- vertices[(i*2)+6] = sin(alpha)*r;
+ alpha += alphastep;
+ vertices[(i*2)+6] = sin(alpha)*r;
}
-
+
alpha = asin(-(width/2)/r);
-
+
for(i=0;i<5;i++){
- alpha +=alphastep;
- vertices[(i*2)+7]= cos(alpha)*r;
+ alpha +=alphastep;
+ vertices[(i*2)+7]= cos(alpha)*r;
}
-
+
vertices[16] = - vertices[4];
vertices[17] = vertices[5];
vertices[18] = - vertices[2];
vertices[19] = vertices[3];
-
+
}
// fgUpdateTurnCoordinator - draws turn coordinator related stuff
void FGTurnCoordinator::Render(void){
int n;
-
+
xglDisable(GL_LIGHTING);
xglDisable(GL_BLEND);
xglEnable(GL_TEXTURE_2D);
-
+
alpha = (get_sideslip() / 1.5) * 560;
if(alpha > 56){
- alpha = 56;
+ alpha = 56;
}
if(alpha < -56){
- alpha = -56;
+ alpha = -56;
}
-
+
PlaneAlpha = get_roll();
-
+
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
-
+
xglMatrixMode(GL_MODELVIEW);
xglLoadIdentity();
xglTranslatef(BallXPos, BallYPos, 0.0);
xglBegin(GL_POLYGON);
xglColor3f(0.8, 0.8, 0.8);
for(i=0;i<36;i++){
- xglVertex2f(vertices[2 * i], vertices[(2 * i) + 1]);
+ xglVertex2f(vertices[2 * i], vertices[(2 * i) + 1]);
}
xglEnd();
-
+
xglDisable(GL_TEXTURE_2D);
xglDisable(GL_BLEND);
-
+
xglMatrixMode(GL_MODELVIEW);
xglLoadIdentity();
xglTranslatef(XPos, YPos, 0.0);
xglRotatef(rollhist[0] * RAD_TO_DEG + 90, 0.0, 0.0, 1.0);
-
+
fgEraseArea(Wings, 8, PlaneTexXPos, PlaneTexYPos, XPos, YPos, 1, 1);
fgEraseArea(Elevator, 8, PlaneTexXPos, PlaneTexYPos, XPos, YPos, 1, 1);
fgEraseArea(Rudder, 8, PlaneTexXPos, PlaneTexYPos, XPos, YPos, 1, 1);
-
+
xglLoadIdentity();
xglTranslatef(XPos, YPos, 0.0);
xglRotatef(-get_roll() * RAD_TO_DEG + 90, 0.0, 0.0, 1.0);
-
+
xglBegin(GL_POLYGON);
xglColor3f(1.0, 1.0, 1.0);
for(i=0;i<90;i++){
- xglVertex2f(cos(i * 4 * DEG_TO_RAD) * 5, sin(i * 4 * DEG_TO_RAD) * 5);
+ xglVertex2f(cos(i * 4 * DEG_TO_RAD) * 5, sin(i * 4 * DEG_TO_RAD) * 5);
}
xglEnd();
-
+
xglBegin(GL_POLYGON);
xglVertex2f(Wings[0], Wings[1]);
xglVertex2f(Wings[2], Wings[3]);
xglVertex2f(Wings[6], Wings[7]);
xglVertex2f(Wings[0], Wings[1]);
xglEnd();
-
+
xglBegin(GL_POLYGON);
xglVertex2f(Elevator[0], Elevator[1]);
xglVertex2f(Elevator[2], Elevator[3]);
xglVertex2f(Elevator[6], Elevator[7]);
xglVertex2f(Elevator[0], Elevator[1]);
xglEnd();
-
+
xglBegin(GL_POLYGON);
xglVertex2f(Rudder[0], Rudder[1]);
xglVertex2f(Rudder[2], Rudder[3]);
xglVertex2f(Rudder[6], Rudder[7]);
xglVertex2f(Rudder[0], Rudder[1]);
xglEnd();
-
-
+
+
alphahist[0] = alphahist[1];
alphahist[1] = alpha;
rollhist[0] = rollhist[1];
rollhist[1] = -get_roll();
-
+
xglDisable(GL_BLEND);
}
BallTexXPos = 49;
BallTexYPos = 16;
BallRadius = 3.5;
-
+
for(n=0;n<36;n++){
- vertices[2 * n] = cos(10 * n * DEG_TO_RAD) * BallRadius;
- vertices[(2 * n) + 1] = sin(10 * n * DEG_TO_RAD) * BallRadius;
- }
+ vertices[2 * n] = cos(10 * n * DEG_TO_RAD) * BallRadius;
+ vertices[(2 * n) + 1] = sin(10 * n * DEG_TO_RAD) * BallRadius;
+ }
}
-void DrawScale(float XPos, float YPos, float InnerRadius, float OuterRadius,
- float alpha1, float alpha2, int steps, float LineWidth,
- float red, float green, float blue, bool filled){
+void DrawScale(float XPos, float YPos, float InnerRadius, float OuterRadius, float alpha1, float alpha2, int steps, float LineWidth,
+ float red, float green, float blue, bool filled){
int i;
float diff = (alpha2 - alpha1) / (float)(steps - 1);
-
+
#define ANTIALIASED_INSTRUMENTS
-
+
#ifdef ANTIALIASED_INSTRUMENTS
xglEnable(GL_LINE_SMOOTH);
xglEnable(GL_BLEND);
xglHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
#endif
-
+
xglMatrixMode(GL_MODELVIEW);
xglLoadIdentity();
-
+
xglTranslatef(XPos, YPos, 0.0);
xglRotatef(-alpha1, 0.0, 0.0, 1.0);
-
+
xglLineWidth(LineWidth);
xglColor3f(red, green, blue);
-
+
if(!filled){
- xglBegin(GL_LINES);
+ xglBegin(GL_LINES);
}
else{
- xglBegin(GL_QUAD_STRIP);
+ xglBegin(GL_QUAD_STRIP);
}
-
+
for(i=0;i < steps; i++){
- xglVertex3f(sin(i * diff * DEG_TO_RAD) * OuterRadius,
- cos(i * diff * DEG_TO_RAD) * OuterRadius, 0.0);
- xglVertex3f(sin(i * diff * DEG_TO_RAD) * InnerRadius,
- cos(i * diff * DEG_TO_RAD) * InnerRadius, 0.0);
+ xglVertex3f(sin(i * diff * DEG_TO_RAD) * OuterRadius,
+ cos(i * diff * DEG_TO_RAD) * OuterRadius,
+ 0.0);
+ xglVertex3f(sin(i * diff * DEG_TO_RAD) * InnerRadius,
+ cos(i * diff * DEG_TO_RAD) * InnerRadius,
+ 0.0);
}
xglEnd();
-
+
xglLoadIdentity();
xglDisable(GL_LINE_SMOOTH);
xglDisable(GL_BLEND);
xglEnable(GL_TEXTURE_2D);
// xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
// xglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
#ifdef GL_VERSION_1_1
xglBindTexture(GL_TEXTURE_2D, panel_tex_id[1]);
#elif GL_EXT_texture_object
#else
# error port me
#endif
-
+
xglBegin(GL_POLYGON);
xglTexCoord2f(.39844, .01953);
xglDisable(GL_BLEND);
xglDisable(GL_TEXTURE_2D);
}
-
+
// PrintMatrix - routine to print the current modelview matrix.
void PrintMatrix( void){
xglGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
- printf("matrix2 = %f %f %f %f \n",
- mvmatrix[0], mvmatrix[1], mvmatrix[2], mvmatrix[3]);
- printf(" %f %f %f %f \n",
- mvmatrix[4], mvmatrix[5], mvmatrix[6], mvmatrix[7]);
- printf(" %f %f %f %f \n",
- mvmatrix[8], mvmatrix[9], mvmatrix[10], mvmatrix[11]);
- printf(" %f %f %f %f \n",
- mvmatrix[12], mvmatrix[13], mvmatrix[14], mvmatrix[15]);
+ printf("matrix2 = %f %f %f %f \n",
+ mvmatrix[0], mvmatrix[1], mvmatrix[2], mvmatrix[3]);
+ printf(" %f %f %f %f \n",
+ mvmatrix[4], mvmatrix[5], mvmatrix[6], mvmatrix[7]);
+ printf(" %f %f %f %f \n",
+ mvmatrix[8], mvmatrix[9], mvmatrix[10], mvmatrix[11]);
+ printf(" %f %f %f %f \n",
+ mvmatrix[12], mvmatrix[13], mvmatrix[14], mvmatrix[15]);
}
void FGRpmGauge::Init(void){
list = xglGenLists (1);
int n;
-
+
xglNewList(list, GL_COMPILE);
-
+
xglColor3f(.26, .289, .3281);
xglBegin(GL_POLYGON);
for(n = 0; n < 180; n++){
- xglVertex2f(cos(n * 0.0349066) * 24.5, sin(n * 0.0349066) * 24.5);
+ xglVertex2f(cos(n * 0.0349066) * 24.5, sin(n * 0.0349066) * 24.5);
}
xglEnd();
-
+
DrawScale(XPos, YPos, 22.5, 25.625, 50, 135, 10, 1.0, 0.0, 0.7, 0.0,FILLED);
DrawScale(XPos, YPos, 21.0, 25.625, -70, 180, 8, 1.8, 0.88, 0.88, 0.88, false);
DrawScale(XPos, YPos, 22.5, 25.0, -70, 180, 40, 0.6, 0.5, 0.5, 0.5, false);
-
+
xglEndList();
}
-
+
void FGRpmGauge::Render(void){
xglMatrixMode(GL_MODELVIEW);
xglLoadIdentity();
xglTranslatef(XPos, YPos, 0.0);
-
+
xglCallList(list);
-
+
}
-
+
void FGPanel::DrawTestLetter(float X, float Y){
xglEnable(GL_TEXTURE_2D);
xglEnable(GL_BLEND);
-
+
xglMatrixMode(GL_TEXTURE);
xglLoadIdentity();
xglTranslatef(X, Y, 0.0);
-
+
DrawLetter();
xglMatrixMode(GL_MODELVIEW);
xglDisable(GL_TEXTURE_2D);
xglDisable(GL_BLEND);
}
-
+
void FGPanel::InitLists(void){
xglNewList(FontList + 'A', GL_COMPILE);
DrawTestLetter(0.391625, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'B', GL_COMPILE);
DrawTestLetter(0.391625 + 1 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'C', GL_COMPILE);
DrawTestLetter(0.391625 + 2 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'D', GL_COMPILE);
DrawTestLetter(0.391625 + 3 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'E', GL_COMPILE);
DrawTestLetter(0.391625 + 4 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'F', GL_COMPILE);
DrawTestLetter(0.391625 + 5 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'G', GL_COMPILE);
DrawTestLetter(0.391625 + 6 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'H', GL_COMPILE);
DrawTestLetter(0.391625 + 7 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'I', GL_COMPILE);
DrawTestLetter(0.391625 + 8 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'J', GL_COMPILE);
DrawTestLetter(0.391625 + 9 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'K', GL_COMPILE);
DrawTestLetter(0.391625 + 9.7 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'L', GL_COMPILE);
DrawTestLetter(0.399625 + 10.6 * LETTER_OFFSET, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'M', GL_COMPILE);
DrawTestLetter(0.80459375, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'N', GL_COMPILE);
DrawTestLetter(0.83975, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'O', GL_COMPILE);
DrawTestLetter(0.871, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'P', GL_COMPILE);
DrawTestLetter(0.90715625, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + 'Q', GL_COMPILE);
DrawTestLetter(0.9413125, 0.29296875);
xglEndList();
-
+
xglNewList(FontList + '1', GL_COMPILE);
DrawTestLetter(0.390625, 0.35546875);
xglEndList();
-
+
xglNewList(FontList + '2', GL_COMPILE);
DrawTestLetter(0.390625 + 1*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '3', GL_COMPILE);
DrawTestLetter(0.390625 + 2*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '4', GL_COMPILE);
DrawTestLetter(0.390625 + 3*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '5', GL_COMPILE);
DrawTestLetter(0.390625 + 4*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '6', GL_COMPILE);
DrawTestLetter(0.390625 + 5*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '7', GL_COMPILE);
DrawTestLetter(0.390625 + 6*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '8', GL_COMPILE);
DrawTestLetter(0.390625 + 7*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '9', GL_COMPILE);
DrawTestLetter(0.390625 + 8*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + '0', GL_COMPILE);
DrawTestLetter(0.383625 + 9*LETTER_OFFSET, 0.3515625);
xglEndList();
-
+
xglNewList(FontList + ' ', GL_COMPILE);
xglTranslatef(8.0, 0.0, 0.0);
xglEndList();
}
-
+
void FGPanel::TexString(char *s, float XPos, float YPos, float size){
xglMatrixMode(GL_MODELVIEW);
xglLoadIdentity();
xglTranslatef(XPos, YPos, 0.0);
xglScalef(size, size, 1.0);
-
+
#ifdef GL_VERSION_1_1
xglBindTexture(GL_TEXTURE_2D, panel_tex_id[1]);
#elif GL_EXT_texture_object
#endif
while((*s) != '\0'){
- xglCallList(FontList + (*s));
- s++;
+ xglCallList(FontList + (*s));
+ s++;
}
xglLoadIdentity();
}
-
+
void FGTexInstrument::Init(void){
CreatePointer();
}
-
+
void FGTexInstrument::Render(void){
xglEnable(GL_TEXTURE_2D);
xglLoadIdentity();
xglTranslatef(XPos, YPos, 0.0);
xglRotatef(-tape[0], 0.0, 0.0, 1.0);
fgEraseArea(vertices, 20, (GLfloat)(teXpos), (GLfloat)(texYpos), (GLfloat)(XPos), (GLfloat)(YPos), 0, 1);
-
+
UpdatePointer();
-
+
xglDisable(GL_TEXTURE_2D);
}
-
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
-
+
#define LETTER_OFFSET 0.03515625
#ifndef _PANEL_HXX
class FGInstrument;
class FGPanel{
-
-private:
-int height, width;
-GLuint FontList;
-
-GLubyte *background;
-
-// FGInstrument **instr_list;
-FGInstrument *test_instr[7];
-
-void GetData(void);
-
-public:
-static FGPanel *OurPanel;
-
- FGPanel(void);
-
-float get_height(void){
- return height;
- }
-
-void ReInit( int x, int y, int finx, int finy);
-void Update(void);
-
-void DrawLetter(void){
- glBegin(GL_POLYGON);
- glTexCoord2f(0.0, 0.0);
- glVertex2f(0.0, 0.0);
- glTexCoord2f(LETTER_OFFSET + 0.004, 0.0);
- glVertex2f(7.0, 0.0);
- glTexCoord2f(LETTER_OFFSET + 0.004, 0.0390625);
- glVertex2f(7.0, 9.0);
- glTexCoord2f(0.0, 0.0390625);
- glVertex2f(0.0, 9.0);
- glEnd();
+
+ private:
+ int height, width;
+ GLuint FontList;
+
+ GLubyte *background;
+
+ // FGInstrument **instr_list;
+ FGInstrument *test_instr[7];
+
+ void GetData(void);
+
+ public:
+ static FGPanel *OurPanel;
+
+ FGPanel(void);
+
+ float get_height(void){
+ return height;
}
-void DrawTestLetter(float X, float Y);
-void InitLists(void);
-void TexString(char *s, float XPos, float YPos, float size);
-
+ void ReInit( int x, int y, int finx, int finy);
+ void Update(void);
+
+ void DrawLetter(void){
+ glBegin(GL_POLYGON);
+ glTexCoord2f(0.0, 0.0);
+ glVertex2f(0.0, 0.0);
+ glTexCoord2f(LETTER_OFFSET + 0.004, 0.0);
+ glVertex2f(7.0, 0.0);
+ glTexCoord2f(LETTER_OFFSET + 0.004, 0.0390625);
+ glVertex2f(7.0, 9.0);
+ glTexCoord2f(0.0, 0.0390625);
+ glVertex2f(0.0, 9.0);
+ glEnd();
+ }
+
+ void DrawTestLetter(float X, float Y);
+ void InitLists(void);
+ void TexString(char *s, float XPos, float YPos, float size);
+
};
class FGInstrument{
-friend class FGPanel;
-
-protected:
-float XPos, YPos;
-
-public:
- FGInstrument(void){
- }
-
- virtual ~FGInstrument(void){}
-
-virtual void Init(void) = 0;
-virtual void Render(void) = 0;
+ friend class FGPanel;
+
+ protected:
+ float XPos, YPos;
+
+ public:
+ FGInstrument(void){
+ }
+
+ virtual ~FGInstrument(void){}
+
+ virtual void Init(void) = 0;
+ virtual void Render(void) = 0;
};
class FGHorizon : public FGInstrument {
-private:
- float texXPos;
- float texYPos;
- float radius;
- float bottom; // tell the program the offset between midpoint and bottom
- float top; // guess what ;-)
- float vertices[180][2];
- float normals[180][3];
- float texCoord[180][2];
-
-public:
- FGHorizon(void){
- XPos = 0.0; YPos = 0.0;
- Init();
- }
-
+ private:
+ float texXPos;
+ float texYPos;
+ float radius;
+ float bottom; // tell the program the offset between midpoint and bottom
+ float top; // guess what ;-)
+ float vertices[180][2];
+ float normals[180][3];
+ float texCoord[180][2];
+
+ public:
+ FGHorizon(void){
+ XPos = 0.0; YPos = 0.0;
+ Init();
+ }
+
FGHorizon(float inXPos, float inYPos){
- XPos = inXPos; YPos = inYPos;
- Init();
+ XPos = inXPos; YPos = inYPos;
+ Init();
}
-virtual void Init(void);
-virtual void Render(void);
-
+ virtual void Init(void);
+ virtual void Render(void);
+
};
class FGTurnCoordinator : public FGInstrument {
-private:
- float PlaneTexXPos;
- float PlaneTexYPos;
- float alpha;
- float PlaneAlpha;
- float alphahist[2];
- float rollhist[2];
- float BallXPos;
- float BallYPos;
- float BallTexXPos;
- float BallTexYPos;
- float BallRadius;
- GLfloat vertices[72];
-
-public:
- FGTurnCoordinator(void){
- XPos = 0.0; YPos = 0.0;
- Init();
- }
-
- FGTurnCoordinator(float inXPos, float inYPos){
- XPos = inXPos; YPos = inYPos;
- Init();
- }
-
-virtual void Init (void);
-virtual void Render(void);
-
+ private:
+ float PlaneTexXPos;
+ float PlaneTexYPos;
+ float alpha;
+ float PlaneAlpha;
+ float alphahist[2];
+ float rollhist[2];
+ float BallXPos;
+ float BallYPos;
+ float BallTexXPos;
+ float BallTexYPos;
+ float BallRadius;
+ GLfloat vertices[72];
+
+ public:
+ FGTurnCoordinator(void){
+ XPos = 0.0; YPos = 0.0;
+ Init();
+ }
+
+ FGTurnCoordinator(float inXPos, float inYPos){
+ XPos = inXPos; YPos = inYPos;
+ Init();
+ }
+
+ virtual void Init (void);
+ virtual void Render(void);
+
};
class FGRpmGauge : public FGInstrument {
-private:
- GLuint list;
-
-public:
- FGRpmGauge(void){
- XPos = 0.0; YPos = 0.0;
- Init();
- }
-
- FGRpmGauge(float inXPos, float inYPos){
- XPos = inXPos; YPos = inYPos;
- Init();
- }
-
-virtual void Init(void);
-virtual void Render(void);
+ private:
+ GLuint list;
+
+ public:
+ FGRpmGauge(void){
+ XPos = 0.0; YPos = 0.0;
+ Init();
+ }
+
+ FGRpmGauge(float inXPos, float inYPos){
+ XPos = inXPos; YPos = inYPos;
+ Init();
+ }
+
+ virtual void Init(void);
+ virtual void Render(void);
};
// temporary class until I get the software-only routines for the
// instruments run
class FGTexInstrument : public FGInstrument {
-
-private:
- float radius;
- float length;
- float width;
- float angle;
- float tape[2];
- float value1;
- float value2;
- float alpha1;
- float alpha2;
- float teXpos;
- float texYpos;
- int variable;
- GLfloat vertices[20];
-public:
- FGTexInstrument(void){
- XPos = 0.0; YPos = 0.0;
- Init();
- }
-
- FGTexInstrument(float inXPos, float inYPos, float inradius, float inlength, float inwidth, float inangle, float invalue1, float invalue2, float inalpha1, float inalpha2, float intexXPos, float intexYPos, int invariable){
-
- XPos = inXPos; YPos = inYPos;
- radius = inradius; angle = inangle;
- length = inlength; width = inwidth;
- value1 = invalue1; value2 = invalue2;
- alpha1 = inalpha1; alpha2 = inalpha2;
- teXpos = intexXPos; texYpos = intexYPos;
- variable = invariable;
- Init();
- }
-
- void CreatePointer(void);
- void UpdatePointer(void);
-
- void Init(void);
- void Render(void);
+ private:
+ float radius;
+ float length;
+ float width;
+ float angle;
+ float tape[2];
+ float value1;
+ float value2;
+ float alpha1;
+ float alpha2;
+ float teXpos;
+ float texYpos;
+ int variable;
+ GLfloat vertices[20];
+
+ public:
+ FGTexInstrument(void){
+ XPos = 0.0; YPos = 0.0;
+ Init();
+ }
+
+ FGTexInstrument(float inXPos, float inYPos, float inradius, float inlength, float inwidth, float inangle, float invalue1, float invalue2, float inalpha1, float inalpha2, float intexXPos, float intexYPos, int invariable){
+
+ XPos = inXPos; YPos = inYPos;
+ radius = inradius; angle = inangle;
+ length = inlength; width = inwidth;
+ value1 = invalue1; value2 = invalue2;
+ alpha1 = inalpha1; alpha2 = inalpha2;
+ teXpos = intexXPos; texYpos = intexYPos;
+ variable = invariable;
+ Init();
+ }
+
+ void CreatePointer(void);
+ void UpdatePointer(void);
+
+ void Init(void);
+ void Render(void);
};
typedef struct{
-float XPos;
-float YPos;
+ float XPos;
+ float YPos;
float radius;
float length;
float width;
void PrintMatrix( void);
#endif // _PANEL_HXX
-
-
-