1 // hud.cxx -- hud defines and prototypes
3 // Written by Michele America, started September 1997.
5 // Copyright (C) 1997 Michele F. America - micheleamerica@geocities.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 # define exception c_exception
41 #include <simgear/constants.h>
42 #include <simgear/debug/logstream.hxx>
43 //#include <simgear/math/fg_random.h>
44 //#include <simgear/math/polar3d.hxx>
46 #include <Aircraft/aircraft.hxx>
47 #include <Autopilot/newauto.hxx>
49 #include <Main/globals.hxx>
51 #include <NetworkOLK/network.h>
53 #include <Scenery/scenery.hxx>
54 //#include <Time/fg_timer.hxx>
56 #if defined ( __sun__ ) || defined ( __sgi )
58 extern void *memmove(void *, const void *, size_t);
66 // The following routines obtain information concerning the aircraft's
67 // current state and return it to calling instrument display routines.
68 // They should eventually be member functions of the aircraft.
71 deque< instr_item * > HUD_deque;
73 fgTextList HUD_TextList;
74 fgLineList HUD_LineList;
75 fgLineList HUD_StippleLineList;
77 fntRenderer *HUDtext = 0;
78 float HUD_TextSize = 0;
82 static float hud_trans_alpha = 0.67f;
84 void fgHUDalphaInit( void );
90 locRECT( UINT left, UINT top, UINT right, UINT bottom);
91 RECT get_rect(void) { return rect;}
94 locRECT :: locRECT( UINT left, UINT top, UINT right, UINT bottom)
105 void drawOneLine( UINT x1, UINT y1, UINT x2, UINT y2)
113 void drawOneLine( RECT &rect)
116 glVertex2f(rect.left, rect.top);
117 glVertex2f(rect.right, rect.bottom);
122 // The following code deals with painting the "instrument" on the display
124 /* textString - Bitmap font string */
126 void textString( int x, int y, char *msg, void *font ){
130 // puDrawString ( NULL, msg, x, y );
133 glutBitmapCharacter(font, *msg);
140 /* strokeString - Stroke font string */
141 void strokeString(int x, int y, char *msg, void *font, float theta)
146 float sintheta,costheta;
152 glRotatef(theta * RAD_TO_DEG, 0.0, 0.0, 1.0);
153 sintheta = sin(theta);
154 costheta = cos(theta);
155 xx = (int)(x * costheta + y * sintheta);
156 yy = (int)(y * costheta - x * sintheta);
157 glTranslatef( xx, yy, 0);
158 glScalef(.1, .1, 0.0);
159 while( (c=*msg++) ) {
160 glutStrokeCharacter(font, c);
166 int getStringWidth ( char *str )
168 if ( HUDtext && str )
171 guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
172 return FloatToInt( r - l );
178 //========================= End of Class Implementations===================
181 // Constructs a HUD object and then adds in instruments. At the present
182 // the instruments are hard coded into the routine. Ultimately these need
183 // to be defined by the aircraft's instrumentation records so that the
184 // display for a Piper Cub doesn't show the speed range of a North American
185 // mustange and the engine readouts of a B36!
190 int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
195 // $$$ begin - added VS Renganathan
204 unsigned int text_h = 10;
205 unsigned int ladr_w2 = 60;
211 // $$$ end - added VS Renganathan
214 int min_x = 25; //off/2;
215 int max_x = 615; //640-(off/2);
217 int max_y = 430; //480-off;
220 unsigned int text_h = 10;
221 unsigned int ladr_w2 = 60;
228 // int font_size = globals->get_options()->get_xsize() / 60;
229 int font_size = (globals->get_options()->get_xsize() > 1000) ? LARGE : SMALL;
233 FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
235 // deque < instr_item * > :: iterator first = HUD_deque.begin();
236 // deque < instr_item * > :: iterator last = HUD_deque.end();
237 // HUD_deque.erase( first, last); // empty the HUD deque
239 HUD_deque.erase( HUD_deque.begin(), HUD_deque.end()); // empty the HUD deque
244 // For now lets just hardcode the hud here.
245 // In the future, hud information has to come from the same place
246 // aircraft information came from.
248 // fgHUDSetTimeMode( hud, NIGHT );
249 // fgHUDSetBrightness( hud, BRT_LIGHT );
252 // int x = 290; /*cen_x-30*/
253 // int y = 45; /*off-5*/
254 // HIptr = (instr_item *) new fgTBI_instr( x, y, ladr_w2, text_h );
255 // $$$ begin - added, VS Renganathan 13 Oct 2K
257 // case 1: // Artificial Horizon
258 HIptr = (instr_item *) new HudLadder( cen_x-ladr_w2, cen_y-ladr_h2,
259 2*ladr_w2, 2*ladr_h2 );
260 HUD_deque.insert( HUD_deque.begin(), HIptr);
262 // case 4: // GYRO COMPASS
263 HIptr = (instr_item *) new hud_card( cen_x-(compass_w/2),
264 cen_y+8.0, //CENTER_DIAMOND_SIZE
276 HUD_deque.insert( HUD_deque.begin(), HIptr);
278 // case 10: // Digital KIAS
279 HIptr = (instr_item *) new instr_label ( cen_x-190,
293 HUD_deque.insert( HUD_deque.begin(), HIptr);
295 HIptr = (instr_item *) new instr_label ( cen_x-180,
309 HUD_deque.insert( HUD_deque.begin(), HIptr);
311 HIptr = (instr_item *) new instr_label ( cen_x+110,
325 HUD_deque.insert( HUD_deque.begin(), HIptr);
327 HIptr = (instr_item *) new instr_label ( cen_x+110,
341 HUD_deque.insert( HUD_deque.begin(), HIptr);
344 HIptr = (instr_item *) new hud_card( cen_x-145.0, //min_x +18,
349 HUDS_LEFT | HUDS_VERT,
350 // HUDS_RIGHT | HUDS_VERT,
358 HUD_deque.insert( HUD_deque.begin(), HIptr);
359 // case 2: // normal acceleration at cg, g's
360 HIptr = (instr_item *) new hud_card( cen_x-185, //min_x +18,
365 HUDS_LEFT | HUDS_VERT,
366 // HUDS_RIGHT | HUDS_VERT,
374 HUD_deque.insert( HUD_deque.begin(), HIptr);
376 HIptr = (instr_item *) new hud_card( (2*cen_x)-195.0, //min_x +18,
380 get_climb_rate, //fix
381 // HUDS_LEFT | HUDS_VERT,
382 HUDS_RIGHT | HUDS_VERT,
390 HUD_deque.insert( HUD_deque.begin(), HIptr);
393 // Aux parameter 16 - xposn
394 HIptr = (instr_item *) new instr_label ( cen_x+170,
408 HUD_deque.insert( HUD_deque.begin(), HIptr);
411 // Aux parameter 17 - xposn
412 HIptr = (instr_item *) new instr_label ( cen_x+170,
426 HUD_deque.insert( HUD_deque.begin(), HIptr);
434 // Aux parameter 1 - xposn
435 HIptr = (instr_item *) new instr_label ( cen_x+240,
449 HUD_deque.insert( HUD_deque.begin(), HIptr);
451 // Aux parameter 2 - pla
452 HIptr = (instr_item *) new instr_label ( cen_x+240,
466 HUD_deque.insert( HUD_deque.begin(), HIptr);
468 // Aux parameter 3 - xtd
469 HIptr = (instr_item *) new instr_label ( cen_x+240,
483 HUD_deque.insert( HUD_deque.begin(), HIptr);
485 // Aux parameter 4 - ytd
486 HIptr = (instr_item *) new instr_label ( cen_x+240,
500 HUD_deque.insert( HUD_deque.begin(), HIptr);
502 // Aux parameter 5 - nztd
503 HIptr = (instr_item *) new instr_label ( cen_x+240,
517 HUD_deque.insert( HUD_deque.begin(), HIptr);
519 // Aux parameter 6 - vvtd
520 HIptr = (instr_item *) new instr_label ( cen_x+240,
534 HUD_deque.insert( HUD_deque.begin(), HIptr);
536 // Aux parameter 7 - vtd
537 HIptr = (instr_item *) new instr_label ( cen_x+240,
551 HUD_deque.insert( HUD_deque.begin(), HIptr);
553 // Aux parameter 8 - alftd
554 HIptr = (instr_item *) new instr_label ( cen_x+240,
568 HUD_deque.insert( HUD_deque.begin(), HIptr);
570 // Aux parameter 9 - fnr
571 HIptr = (instr_item *) new instr_label ( cen_x+240,
585 HUD_deque.insert( HUD_deque.begin(), HIptr);
587 // Aux parameter 10 - Ax
588 HIptr = (instr_item *) new instr_label ( cen_x+240,
602 HUD_deque.insert( HUD_deque.begin(), HIptr);
604 // $$$ end - added , VS Renganathan 13 Oct 2K
606 HIptr = (instr_item *) new fgTBI_instr( 290, 45, 60, 10 );
607 HUD_deque.insert( HUD_deque.begin(), HIptr);
609 // case 1: // Artificial Horizon
610 HIptr = (instr_item *) new HudLadder( cen_x-ladr_w2, cen_y-ladr_h2,
611 2*ladr_w2, 2*ladr_h2 );
612 HUD_deque.insert( HUD_deque.begin(), HIptr);
614 // case 4: // GYRO COMPASS
615 HIptr = (instr_item *) new hud_card( cen_x-(compass_w/2),
628 HUD_deque.insert( HUD_deque.begin(), HIptr);
631 HIptr = (instr_item *) new hud_card( max_x - 35 -15, // 15 to balance speed card
636 // HUDS_RIGHT | HUDS_VERT,
637 HUDS_LEFT | HUDS_VERT,
645 HUD_deque.insert( HUD_deque.begin(), HIptr);
648 HIptr = (instr_item *) new guage_instr( cen_x-50, // x
649 cen_y + ladr_h2 -20, // y
652 get_aileronval, // data source
653 HUDS_BOTTOM | HUDS_NOTEXT,
657 HUD_deque.insert( HUD_deque.begin(), HIptr);
659 // case 3: // Radio Altimeter
660 HIptr = (instr_item *) new hud_card( cen_x + ladr_w2 + gap + 13 + ladr_t,
665 HUDS_LEFT | HUDS_VERT,
673 HUD_deque.insert( HUD_deque.begin(), HIptr);
676 HIptr = (instr_item *) new guage_instr( cen_x -ladr_w2 -gap -13 -20 -ladr_t,
680 get_elevatorval, // data source
681 HUDS_RIGHT | HUDS_VERT | HUDS_NOTEXT,
682 -100.0, // Scale data
685 HUD_deque.insert( HUD_deque.begin(), HIptr);
688 HIptr = (instr_item *) new guage_instr( cen_x-50, // x
689 cen_y -gap -ladr_w2 -20, //-85 // y
692 get_rudderval, // data source
693 HUDS_TOP | HUDS_NOTEXT,
697 HUD_deque.insert( HUD_deque.begin(), HIptr);
700 HIptr = (instr_item *) new hud_card( min_x +10 +5, //min_x +18,
705 // HUDS_LEFT | HUDS_VERT,
706 HUDS_RIGHT | HUDS_VERT,
717 HUD_deque.insert( HUD_deque.begin(), HIptr);
720 // case 10: // Digital Mach number
721 HIptr = (instr_item *) new instr_label ( min_x , //same as speed tape
722 cen_y-(compass_w/2) -10, //below speed tape
735 HUD_deque.insert( HUD_deque.begin(), HIptr);
738 HIptr = (instr_item *) new guage_instr( min_x-10, // x
742 get_throttleval, // data source
743 // HUDS_VERT | HUDS_RIGHT | HUDS_NOTEXT,
744 HUDS_VERT | HUDS_LEFT | HUDS_NOTEXT, 100.0,
748 HUD_deque.insert( HUD_deque.begin(), HIptr);
750 // Remove this when below uncommented
752 HIptr = (instr_item *) new instr_label( 10,
766 HUD_deque.insert( HUD_deque.begin(), HIptr);
768 // $$$ begin - added VS Renganthan 19 Oct 2K
770 HIptr = (instr_item *) new lat_label( 70,
784 HUD_deque.insert( HUD_deque.begin(), HIptr);
786 HIptr = (instr_item *) new lon_label( 475,
799 HUD_deque.insert( HUD_deque.begin(), HIptr);
801 HIptr = (instr_item *) new lat_label( (cen_x - (compass_w/2))/2,
815 HUD_deque.insert( HUD_deque.begin(), HIptr);
817 HIptr = (instr_item *) new lon_label(((cen_x+compass_w/2)+(2*cen_x))/2,
830 HUD_deque.insert( HUD_deque.begin(), HIptr);
832 // $$$ end - added VS Renganthan 19 Oct 2K
834 // case 10: // Digital KIAS
835 HIptr = (instr_item *) new instr_label ( 110,
849 HUD_deque.insert( HUD_deque.begin(), HIptr);
851 // case 11: // Digital Rate of Climb
852 HIptr = (instr_item *) new instr_label ( 110,
866 HUD_deque.insert( HUD_deque.begin(), HIptr);
868 // case 12: // Roll indication diagnostic
869 HIptr = (instr_item *) new instr_label ( 110,
883 HUD_deque.insert( HUD_deque.begin(), HIptr);
885 // case 13: // Angle of attack diagnostic
886 HIptr = (instr_item *) new instr_label ( 440,
900 HUD_deque.insert( HUD_deque.begin(), HIptr);
903 HIptr = (instr_item *) new instr_label ( 440,
917 HUD_deque.insert( HUD_deque.begin(), HIptr);
920 HIptr = (instr_item *) new instr_label ( 440,
934 HUD_deque.insert( HUD_deque.begin(), HIptr);
937 HIptr = (instr_item *) new instr_label( 440,
951 HUD_deque.insert( HUD_deque.begin(), HIptr);
954 HIptr = (instr_item *) new instr_label( 440,
968 HUD_deque.insert( HUD_deque.begin(), HIptr);
971 HIptr = (instr_item *) new instr_label( 440,
985 HUD_deque.insert( HUD_deque.begin(), HIptr);
988 HIptr = (instr_item *) new instr_label( 10,
1002 HUD_deque.insert( HUD_deque.begin(), HIptr);
1005 switch( globals->get_options()->get_tris_or_culled() ) {
1007 HIptr = (instr_item *) new instr_label( 10,
1023 HIptr = (instr_item *) new instr_label( 10,
1042 HIptr = (instr_item *) new instr_label( 10,
1056 HUD_deque.insert( HUD_deque.begin(), HIptr);
1061 // if( HIptr ) { // Anything to install?
1062 // HUD_deque.insert( HUD_deque.begin(), HIptr);
1070 return 0; // For now. Later we may use this for an error code.
1074 int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
1076 // instr_item *HIptr;
1081 // int max_x = 640-off;
1083 int max_y = 480-off;
1084 int cen_x = 640 / 2;
1085 int cen_y = 480 / 2;
1090 int compass_w = 200;
1093 // int font_size = globals->get_options()->get_xsize() / 60;
1094 int font_size = (globals->get_options()->get_xsize() > 1000) ? LARGE : SMALL;
1098 FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
1100 // deque < instr_item * > :: iterator first = HUD_deque.begin();
1101 // deque < instr_item * > :: iterator last = HUD_deque.end();
1102 // HUD_deque.erase( first, last); // empty the HUD deque
1103 HUD_deque.erase( HUD_deque.begin(), HUD_deque.end());
1108 // For now lets just hardcode the hud here.
1109 // In the future, hud information has to come from the same place
1110 // aircraft information came from.
1112 // fgHUDSetTimeMode( hud, NIGHT );
1113 // fgHUDSetBrightness( hud, BRT_LIGHT );
1120 p = new HudLadder( cen_x-ladr_w2, cen_y-ladr_h2, 2*ladr_w2, 2*ladr_h2, 1 );
1121 HUD_deque.push_front( p );
1123 // case 4: // GYRO COMPASS
1124 p =new hud_card( cen_x-(compass_w/2),
1137 HUD_deque.push_front( p );
1139 p = new lat_label( (cen_x - compass_w/2)/2,
1152 HUD_deque.push_front( p );
1154 // p = new instr_label( 140, 450, 60, 10,
1165 // HUD_deque.push_front( p );
1167 p = new lon_label(((cen_x+compass_w/2)+(2*cen_x))/2,
1180 HUD_deque.push_front( p );
1184 p = new instr_label( x_pos, 25, 60, 10,
1195 HUD_deque.push_front( p );
1197 p = new instr_label( x_pos, 40, 120, 10,
1198 get_vfc_tris_culled,
1208 HUD_deque.push_front( p );
1210 p = new instr_label( x_pos, 55, 120, 10,
1221 HUD_deque.push_front( p );
1224 // p = new instr_label( x_pos, 70, 90, 10,
1225 p = new instr_label( x_pos, 40, 90, 10,
1236 HUD_deque.push_front( p );
1240 p = new instr_label ( x_pos,
1254 HUD_deque.push_front( p );
1256 p = new instr_label( x_pos, 55, 40, 30,
1267 HUD_deque.push_front( p );
1269 if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
1270 strcpy(units, " ft");
1272 strcpy(units, " m");
1274 p = new instr_label( x_pos, 40, 40, 10,
1285 HUD_deque.push_front( p );
1287 p = new instr_label( x_pos, 25, 40, 10,
1298 HUD_deque.push_front( p );
1300 p = new instr_label( x_pos, 10, 60, 10,
1311 HUD_deque.push_front( p );
1313 p = new fgTBI_instr( 290, 55, 60, 10 ); // 270
1314 HUD_deque.push_front( p );
1316 p = new guage_instr( 270, //250, // x
1317 390, //360, //400, //45, //420, // y
1320 get_aileronval, // data source
1321 HUDS_BOTTOM | HUDS_NOTEXT,
1325 HUD_deque.push_front( p );
1327 p = new guage_instr( 20, // x
1331 get_elevatorval, // data source
1332 HUDS_RIGHT | HUDS_VERT | HUDS_NOTEXT,
1333 -100.0, // Scale data
1336 HUD_deque.push_front( p );
1338 p = new guage_instr( 270, //250, // x
1342 get_rudderval, // data source
1343 HUDS_TOP | HUDS_NOTEXT,
1347 HUD_deque.push_front( p );
1349 p = new guage_instr( 600, // x
1353 get_throttleval, // data source
1354 HUDS_VERT | HUDS_LEFT | HUDS_NOTEXT,
1358 HUD_deque.push_front( p );
1360 return 0; // For now. Later we may use this for an error code.
1363 int global_day_night_switch = DAY;
1365 void HUD_masterswitch( bool incr )
1367 if ( globals->get_options()->get_hud_status() ) {
1368 if ( global_day_night_switch == DAY ) {
1369 global_day_night_switch = NIGHT;
1371 globals->get_options()->set_hud_status( false );
1374 globals->get_options()->set_hud_status( true );
1375 global_day_night_switch = DAY;
1379 void HUD_brightkey( bool incr_bright )
1381 instr_item *pHUDInstr = HUD_deque[0];
1382 int brightness = pHUDInstr->get_brightness();
1384 if( globals->get_options()->get_hud_status() ) {
1389 brightness = BRT_BLACK;
1393 brightness = BRT_LIGHT;
1397 brightness = BRT_MEDIUM;
1401 brightness = BRT_DARK;
1405 brightness = BRT_BLACK;
1411 brightness = BRT_MEDIUM;
1415 brightness = BRT_DARK;
1419 brightness = BRT_BLACK;
1423 brightness = BRT_LIGHT;
1427 globals->get_options()->set_hud_status(0);
1431 globals->get_options()->set_hud_status(true);
1434 pHUDInstr->SetBrightness( brightness );
1438 #define fgAP_CLAMP(val,min,max) ( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) )
1440 static puDialogBox *HUDalphaDialog;
1441 static puText *HUDalphaText;
1442 static puSlider *HUDalphaHS0;
1443 //static puText *HUDtextText;
1444 //static puSlider *HUDalphaHS1;
1445 static char SliderText[2][ 8 ];
1447 static void alpha_adj( puObject *hs ) {
1450 hs-> getValue ( &val ) ;
1451 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
1452 // printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
1453 hud_trans_alpha = val;
1454 sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
1455 HUDalphaText -> setLabel ( SliderText[ 0 ] ) ;
1458 void fgHUDalphaAdjust( puObject * ) {
1459 globals->get_options()->set_anti_alias_hud(1);
1460 FG_PUSH_PUI_DIALOG( HUDalphaDialog );
1463 static void goAwayHUDalphaAdjust (puObject *)
1465 FG_POP_PUI_DIALOG( HUDalphaDialog );
1468 static void cancelHUDalphaAdjust (puObject *)
1470 globals->get_options()->set_anti_alias_hud(0);
1471 FG_POP_PUI_DIALOG( HUDalphaDialog );
1474 // Done once at system initialization
1475 void fgHUDalphaInit( void ) {
1477 // printf("fgHUDalphaInit\n");
1478 #define HORIZONTAL FALSE
1482 int DialogWidth = 240;
1484 char Label[] = "HUD Adjuster";
1487 int labelX = (DialogWidth / 2) -
1488 (puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
1493 int slider_width = 220;
1494 int slider_title_x = 15;
1495 int slider_value_x = 160;
1496 float slider_delta = 0.05f;
1498 puFont HUDalphaLegendFont;
1499 puFont HUDalphaLabelFont;
1500 puGetDefaultFonts ( &HUDalphaLegendFont, &HUDalphaLabelFont );
1502 HUDalphaDialog = new puDialogBox ( DialogX, DialogY ); {
1503 int horiz_slider_height = puGetStringHeight (HUDalphaLabelFont) +
1504 puGetStringDescender (HUDalphaLabelFont) +
1505 PUSTR_TGAP + PUSTR_BGAP + 5;
1508 HUDalphaFrame = new puFrame ( 0, 0,
1510 85 + nSliders * horiz_slider_height );
1513 HUDalphaDialogMessage = new puText ( labelX,
1515 * horiz_slider_height );
1516 HUDalphaDialogMessage -> setDefaultValue ( Label );
1517 HUDalphaDialogMessage -> getDefaultValue ( &s );
1518 HUDalphaDialogMessage -> setLabel ( s );
1520 HUDalphaHS0 = new puSlider ( slider_x, slider_y,
1521 slider_width, HORIZONTAL ) ;
1522 HUDalphaHS0-> setDelta ( slider_delta ) ;
1523 HUDalphaHS0-> setValue ( hud_trans_alpha ) ;
1524 HUDalphaHS0-> setCBMode ( PUSLIDER_DELTA ) ;
1525 HUDalphaHS0-> setCallback ( alpha_adj ) ;
1528 HUDalphaTitle = new puText ( slider_title_x, slider_y ) ;
1529 HUDalphaTitle-> setDefaultValue ( "Alpha" ) ;
1530 HUDalphaTitle-> getDefaultValue ( &s ) ;
1531 HUDalphaTitle-> setLabel ( s ) ;
1533 HUDalphaText = new puText ( slider_value_x, slider_y ) ;
1534 sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
1535 HUDalphaText-> setLabel ( SliderText[ 0 ] ) ;
1539 HUDalphaOkButton = new puOneShot ( 10, 10, 60, 45 );
1540 HUDalphaOkButton-> setLegend ( gui_msg_OK );
1541 HUDalphaOkButton-> makeReturnDefault ( TRUE );
1542 HUDalphaOkButton-> setCallback ( goAwayHUDalphaAdjust );
1545 HUDalphaNoButton = new puOneShot ( 160, 10, 230, 45 );
1546 HUDalphaNoButton-> setLegend ( gui_msg_CANCEL );
1547 HUDalphaNoButton-> setCallback ( cancelHUDalphaAdjust );
1549 FG_FINALIZE_PUI_DIALOG( HUDalphaDialog );
1554 void fgHUDReshape(void) {
1558 HUD_TextSize = globals->get_options()->get_xsize() / 60;
1560 HUDtext = new fntRenderer();
1561 HUDtext -> setFont ( guiFntHandle ) ;
1562 HUDtext -> setPointSize ( HUD_TextSize ) ;
1563 HUD_TextList.setFont( HUDtext );
1567 static void set_hud_color(float r, float g, float b) {
1568 globals->get_options()->get_anti_alias_hud() ?
1569 glColor4f(r,g,b,hud_trans_alpha) :
1575 // Performs a once around the list of calls to instruments installed in
1576 // the HUD object with requests for redraw. Kinda. It will when this is
1579 void fgUpdateHUD( void ) {
1581 // int day_night_sw = current_aircraft.controls->day_night_switch;
1582 int day_night_sw = global_day_night_switch;
1583 int hud_displays = HUD_deque.size();
1584 instr_item *pHUDInstr;
1587 if( !hud_displays ) { // Trust everyone, but ALWAYS cut the cards!
1591 HUD_TextList.erase();
1592 HUD_LineList.erase();
1593 // HUD_StippleLineList.erase();
1595 pHUDInstr = HUD_deque[0];
1596 brightness = pHUDInstr->get_brightness();
1597 // brightness = HUD_deque.at(0)->get_brightness();
1599 glMatrixMode(GL_PROJECTION);
1603 gluOrtho2D(0, 640, 0, 480);
1604 glMatrixMode(GL_MODELVIEW);
1608 glDisable(GL_DEPTH_TEST);
1609 glDisable(GL_LIGHTING);
1611 if( globals->get_options()->get_anti_alias_hud() ) {
1612 glEnable(GL_LINE_SMOOTH);
1613 // glEnable(GL_BLEND);
1614 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1615 glHint(GL_LINE_SMOOTH_HINT,GL_DONT_CARE);
1621 if( day_night_sw == DAY) {
1625 set_hud_color (0.1f, 0.9f, 0.1f);
1629 set_hud_color (0.1f, 0.7f, 0.0f);
1633 set_hud_color (0.0f, 0.6f, 0.0f);
1637 set_hud_color( 0.0f, 0.0f, 0.0f);
1641 set_hud_color (0.1f, 0.9f, 0.1f);
1644 if( day_night_sw == NIGHT) {
1648 set_hud_color (0.9f, 0.1f, 0.1f);
1652 set_hud_color (0.7f, 0.0f, 0.1f);
1656 set_hud_color (0.6f, 0.0f, 0.0f);
1660 set_hud_color( 0.0f, 0.0f, 0.0f);
1664 set_hud_color (0.6f, 0.0f, 0.0f);
1666 } else { // Just in case default
1667 set_hud_color (0.1f, 0.9f, 0.1f);
1671 deque < instr_item * > :: iterator current = HUD_deque.begin();
1672 deque < instr_item * > :: iterator last = HUD_deque.end();
1674 for ( ; current != last; ++current ) {
1675 pHUDInstr = *current;
1677 if( pHUDInstr->enabled()) {
1678 // fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
1679 // hud->code, hud->status );
1684 char *gmt_str = get_formated_gmt_time();
1685 HUD_TextList.add( fgText(40, 10, gmt_str) );
1687 #ifdef FG_NETWORK_OLK
1688 if ( net_hud_display ) {
1695 // extern bool fgAPAltitudeEnabled( void );
1696 // extern bool fgAPHeadingEnabled( void );
1697 // extern bool fgAPWayPointEnabled( void );
1698 // extern char *fgAPget_TargetDistanceStr( void );
1699 // extern char *fgAPget_TargetHeadingStr( void );
1700 // extern char *fgAPget_TargetAltitudeStr( void );
1701 // extern char *fgAPget_TargetLatLonStr( void );
1704 // char scratch[128];
1705 // HUD_TextList.add( fgText( "AUTOPILOT", 20, apY) );
1707 if( current_autopilot->get_HeadingEnabled() ) {
1708 HUD_TextList.add( fgText( 40, apY,
1709 current_autopilot->get_TargetHeadingStr()) );
1712 if( current_autopilot->get_AltitudeEnabled() ) {
1713 HUD_TextList.add( fgText( 40, apY,
1714 current_autopilot->get_TargetAltitudeStr()) );
1717 if( current_autopilot->get_HeadingMode() ==
1718 FGAutopilot::FG_HEADING_WAYPOINT )
1721 wpstr = current_autopilot->get_TargetWP1Str();
1722 if ( strlen( wpstr ) ) {
1723 HUD_TextList.add( fgText( 40, apY, wpstr ) );
1726 wpstr = current_autopilot->get_TargetWP2Str();
1727 if ( strlen( wpstr ) ) {
1728 HUD_TextList.add( fgText( 40, apY, wpstr ) );
1731 wpstr = current_autopilot->get_TargetWP3Str();
1732 if ( strlen( wpstr ) ) {
1733 HUD_TextList.add( fgText( 40, apY, wpstr ) );
1738 HUD_TextList.draw();
1740 HUD_LineList.draw();
1742 // glEnable(GL_LINE_STIPPLE);
1743 // glLineStipple( 1, 0x00FF );
1744 // HUD_StippleLineList.draw();
1745 // glDisable(GL_LINE_STIPPLE);
1747 if( globals->get_options()->get_anti_alias_hud() ) {
1748 // glDisable(GL_BLEND);
1749 glDisable(GL_LINE_SMOOTH);
1753 glEnable(GL_DEPTH_TEST);
1754 glEnable(GL_LIGHTING);
1755 glMatrixMode(GL_PROJECTION);
1757 glMatrixMode(GL_MODELVIEW);