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.
23 #include <simgear/compiler.h>
24 #include <simgear/misc/exception.hxx>
35 # define exception c_exception
44 #include <simgear/constants.h>
45 #include <simgear/debug/logstream.hxx>
46 #include <simgear/misc/props.hxx>
47 //#include <simgear/math/fg_random.h>
48 //#include <simgear/math/polar3d.hxx>
50 #include <Aircraft/aircraft.hxx>
51 #include <Autopilot/newauto.hxx>
53 #include <Main/globals.hxx>
54 #include <Main/fg_props.hxx>
55 #include <Main/viewmgr.hxx>
57 #include <NetworkOLK/network.h>
59 #include <Scenery/scenery.hxx>
60 //#include <Time/fg_timer.hxx>
62 #if defined ( __sun__ ) || defined ( __sgi )
64 extern void *memmove(void *, const void *, size_t);
72 // The following routines obtain information concerning the aircraft's
73 // current state and return it to calling instrument display routines.
74 // They should eventually be member functions of the aircraft.
77 deque< instr_item * > HUD_deque;
79 fgTextList HUD_TextList;
80 fgLineList HUD_LineList;
81 fgLineList HUD_StippleLineList;
83 fntRenderer *HUDtext = 0;
84 float HUD_TextSize = 0;
88 static float hud_trans_alpha = 0.67f;
91 //$$$ begin - added, Neetha, 28 Nov 2k
99 static float span_units;
100 static float division_units;
101 static float minor_division = 0;
102 static UINT screen_hole;
105 static string loadfn;
107 static float maxValue;
108 static float minValue;
109 static float scaling;
110 static UINT major_divs;
111 static UINT minor_divs;
112 static UINT modulator;
113 static int dp_showing = 0;
114 static string label_format;
115 static string prelabel;
116 static string postlabel;
119 static float maxBankAngle;
120 static float maxSlipAngle;
121 static UINT gap_width;
122 static bool latitude;
123 static bool longitude;
124 static bool tick_bottom;
125 static bool tick_top;
126 static bool tick_right;
127 static bool tick_left;
128 static bool cap_bottom;
130 static bool cap_right;
131 static bool cap_left;
132 static float marker_off;
134 static bool enable_pointer;
135 static string type_pointer;
136 static bool frl_spot;
138 static bool vel_vector;
142 static bool climb_dive;
144 static float glide_slope_val;
145 static bool worm_energy;
146 static bool waypoint;
148 static FLTFNPTR load_fn;
149 static fgLabelJust justification;
150 static const char *pre_label_string = 0;
151 static const char *post_label_string = 0;
153 int readHud( istream &input );
154 int readInstrument ( const SGPropertyNode * node);
155 static instr_item * readLadder ( const SGPropertyNode * node);
156 static instr_item * readCard ( const SGPropertyNode * node);
157 static instr_item * readLabel( const SGPropertyNode * node);
158 static instr_item * readTBI( const SGPropertyNode * node);
159 //$$$ end - added, Neetha, 28 Nov 2k
161 void fgHUDalphaInit( void );
167 locRECT( UINT left, UINT top, UINT right, UINT bottom);
168 RECT get_rect(void) { return rect;}
171 locRECT :: locRECT( UINT left, UINT top, UINT right, UINT bottom)
176 rect.bottom = bottom;
182 void drawOneLine( UINT x1, UINT y1, UINT x2, UINT y2)
190 void drawOneLine( RECT &rect)
193 glVertex2f(rect.left, rect.top);
194 glVertex2f(rect.right, rect.bottom);
199 // The following code deals with painting the "instrument" on the display
201 /* textString - Bitmap font string */
203 void textString( int x, int y, char *msg, void *font ){
207 // puDrawString ( NULL, msg, x, y );
210 glutBitmapCharacter(font, *msg);
217 /* strokeString - Stroke font string */
218 void strokeString(int x, int y, char *msg, void *font, float theta)
223 float sintheta,costheta;
229 glRotatef(theta * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
230 sintheta = sin(theta);
231 costheta = cos(theta);
232 xx = (int)(x * costheta + y * sintheta);
233 yy = (int)(y * costheta - x * sintheta);
234 glTranslatef( xx, yy, 0);
235 glScalef(.1, .1, 0.0);
236 while( (c=*msg++) ) {
237 glutStrokeCharacter(font, c);
243 int getStringWidth ( char *str )
245 if ( HUDtext && str )
248 guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
249 return FloatToInt( r - l );
255 //========================= End of Class Implementations===================
258 // Constructs a HUD object and then adds in instruments. At the present
259 // the instruments are hard coded into the routine. Ultimately these need
260 // to be defined by the aircraft's instrumentation records so that the
261 // display for a Piper Cub doesn't show the speed range of a North American
262 // mustange and the engine readouts of a B36!
267 //$$$ begin - added, Neetha, 28 Nov 2k
269 readLadder(const SGPropertyNode * node)
274 name = node->getStringValue("name");
275 x = node->getIntValue("x");
276 y = node->getIntValue("y");
277 width = node->getIntValue("width");
278 height = node->getIntValue("height");
279 factor = node->getFloatValue("compression_factor");
280 span_units = node->getFloatValue("span_units");
281 division_units = node->getFloatValue("division_units");
282 screen_hole = node->getIntValue("screen_hole");
283 lbl_pos = node->getIntValue("lbl_pos");
284 frl_spot = node->getBoolValue("enable_frl",false);
285 target = node->getBoolValue("enable_target_spot",false);
286 vel_vector = node->getBoolValue("enable_velocity_vector",false);
287 drift = node->getBoolValue("enable_drift_marker",false);
288 alpha = node->getBoolValue("enable_alpha_bracket",false);
289 energy = node->getBoolValue("enable_energy_marker",false);
290 climb_dive = node->getBoolValue("enable_climb_dive_marker",false);
291 glide = node->getBoolValue("enable_glide_slope_marker",false);
292 glide_slope_val = node->getFloatValue("glide_slope",-4.0);
293 worm_energy = node->getBoolValue("enable_energy_marker",false);
294 waypoint = node->getBoolValue("enable_waypoint_marker",false);
295 working = node->getBoolValue("working");
297 SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
300 p = (instr_item *) new HudLadder( name, x, y,
301 width, height, factor,
303 span_units, division_units, minor_division,
304 screen_hole, lbl_pos, frl_spot, target, vel_vector,
305 drift, alpha, energy, climb_dive,
306 glide, glide_slope_val, worm_energy,
314 readCard(const SGPropertyNode * node)
319 name = node->getStringValue("name");
320 x = node->getIntValue("x");
321 y = node->getIntValue("y");
322 width = node->getIntValue("width");
323 height = node->getIntValue("height");
324 loadfn = node->getStringValue("loadfn");
325 options = node->getIntValue("options");
326 maxValue = node->getFloatValue("maxValue");
327 minValue = node->getFloatValue("minValue");
328 scaling = node->getFloatValue("disp_scaling");
329 major_divs = node->getIntValue("major_divs");
330 minor_divs = node->getIntValue("minor_divs");
331 modulator = node->getIntValue("modulator");
332 span_units = node->getFloatValue("value_span");
333 type = node->getStringValue("type");
334 tick_bottom = node->getBoolValue("tick_bottom",false);
335 tick_top = node->getBoolValue("tick_top",false);
336 tick_right = node->getBoolValue("tick_right",false);
337 tick_left = node->getBoolValue("tick_left",false);
338 cap_bottom = node->getBoolValue("cap_bottom",false);
339 cap_top = node->getBoolValue("cap_top",false);
340 cap_right = node->getBoolValue("cap_right",false);
341 cap_left = node->getBoolValue("cap_left",false);
342 marker_off = node->getFloatValue("marker_offset",0.0);
343 enable_pointer = node->getBoolValue("enable_pointer",true);
344 type_pointer = node->getStringValue("pointer_type");
345 working = node->getBoolValue("working");
348 SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
352 span_units = maxValue - minValue;
357 if(loadfn=="heading")
358 load_fn = get_heading;
364 load_fn = get_climb_rate;
366 if(loadfn=="altitude")
367 load_fn = get_altitude;
375 if(loadfn=="view_direction")
376 load_fn = get_view_direction;
378 if(loadfn=="aileronval")
379 load_fn = get_aileronval;
381 if(loadfn=="elevatorval")
382 load_fn = get_elevatorval;
384 if(loadfn=="rudderval")
385 load_fn = get_rudderval;
387 if(loadfn=="throttleval")
388 load_fn = get_throttleval;
391 p = (instr_item *) new hud_card( x,
399 major_divs, minor_divs,
420 readLabel(const SGPropertyNode * node)
424 int font_size = (fgGetInt("/sim/startup/xsize") > 1000) ? LARGE : SMALL;
426 name = node->getStringValue("name");
427 x = node->getIntValue("x");
428 y = node->getIntValue("y");
429 width = node->getIntValue("width");
430 height = node->getIntValue("height");
431 loadfn = node->getStringValue("data_source");
432 label_format = node->getStringValue("label_format");
433 prelabel = node->getStringValue("pre_label_string");
434 postlabel = node->getStringValue("post_label_string");
435 scaling = node->getFloatValue("scale_data");
436 options = node->getIntValue("options");
437 justi = node->getIntValue("justification");
438 blinking = node->getIntValue("blinking");
439 latitude = node->getBoolValue("latitude",false);
440 longitude = node->getBoolValue("longitude",false);
441 working = node->getBoolValue("working");
444 SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
448 justification = LEFT_JUST;
451 justification = CENTER_JUST;
454 justification = RIGHT_JUST;
459 if ( prelabel == "NULL" ) {
460 pre_label_string = NULL;
462 if ( prelabel == "blank" ) {
463 pre_label_string = " ";
465 pre_label_string = prelabel.c_str();
469 if ( postlabel == "blank" ) {
470 post_label_string = " ";
472 if ( postlabel == "NULL" ) {
473 post_label_string = NULL;
475 if ( postlabel == "units" ) {
476 post_label_string = units;
478 post_label_string = postlabel.c_str();
483 if ( loadfn == "aux16" ) {
485 } else if ( loadfn == "aux17" ) {
487 } else if ( loadfn == "aux9" ) {
489 } else if ( loadfn == "aux11" ) {
491 } else if ( loadfn == "aux12" ) {
493 } else if ( loadfn == "aux10" ) {
495 } else if ( loadfn == "aux13" ) {
497 } else if ( loadfn == "aux14" ) {
499 } else if ( loadfn == "aux15" ) {
501 } else if ( loadfn == "aux8" ) {
503 } else if ( loadfn == "ax" ) {
505 } else if ( loadfn == "speed" ) {
507 } else if ( loadfn == "mach" ) {
509 } else if ( loadfn == "altitude" ) {
510 load_fn = get_altitude;
511 } else if ( loadfn == "agl" ) {
513 } else if ( loadfn == "framerate" ) {
514 load_fn = get_frame_rate;
515 } else if ( loadfn == "heading" ) {
516 load_fn = get_heading;
517 } else if ( loadfn == "fov" ) {
519 } else if ( loadfn == "vfc_tris_culled" ) {
520 load_fn = get_vfc_tris_culled;
521 } else if ( loadfn == "vfc_tris_drawn" ) {
522 load_fn = get_vfc_tris_drawn;
523 } else if ( loadfn == "aoa" ) {
525 } else if ( loadfn == "latitude" ) {
526 load_fn = get_latitude;
527 } else if ( loadfn == "longitude" ) {
528 load_fn = get_longitude;
531 p = (instr_item *) new instr_label ( x,
536 label_format.c_str(),
552 readTBI(const SGPropertyNode * node)
557 name = node->getStringValue("name");
558 x = node->getIntValue("x");
559 y = node->getIntValue("y");
560 width = node->getIntValue("width");
561 height = node->getIntValue("height");
562 maxBankAngle = node->getFloatValue("maxBankAngle");
563 maxSlipAngle = node->getFloatValue("maxSlipAngle");
564 gap_width = node->getIntValue("gap_width");
565 working = node->getBoolValue("working");
567 SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
570 p = (instr_item *) new fgTBI_instr( x,
585 int readInstrument(const SGPropertyNode * node)
590 if ( fgGetString("/sim/startup/units") == "feet" ) {
591 strcpy(units, " ft");
596 const SGPropertyNode * ladder_group = node->getNode("ladders");
598 if (ladder_group != 0) {
599 int nLadders = ladder_group->nChildren();
600 for (int j = 0; j < nLadders; j++) {
602 HIptr = readLadder(ladder_group->getChild(j));
603 HUD_deque.insert( HUD_deque.begin(), HIptr);
608 const SGPropertyNode * card_group = node->getNode("cards");
609 if (card_group != 0) {
610 int nCards = card_group->nChildren();
611 for (int j = 0; j < nCards; j++) {
613 HIptr = readCard(card_group->getChild(j));
614 HUD_deque.insert( HUD_deque.begin(), HIptr);
619 const SGPropertyNode * label_group = node->getNode("labels");
620 if (label_group != 0) {
621 int nLabels = label_group->nChildren();
622 for (int j = 0; j < nLabels; j++) {
624 HIptr = readLabel(label_group->getChild(j));
625 HUD_deque.insert( HUD_deque.begin(), HIptr);
630 const SGPropertyNode * tbi_group = node->getNode("tbis");
631 if (tbi_group != 0) {
632 int nTbis = tbi_group->nChildren();
633 for (int j = 0; j < nTbis; j++) {
635 HIptr = readTBI(tbi_group->getChild(j));
636 HUD_deque.insert( HUD_deque.begin(), HIptr);
641 }//end readinstrument
644 int readHud( istream &input )
650 readProperties(input, &root);
651 } catch (const sg_io_exception &e) {
652 string message = "Error reading HUD: ";
653 message += e.getMessage();
655 message += e.getLocation().asString();
656 SG_LOG(SG_INPUT, SG_ALERT, message);
657 mkDialog(message.c_str());
662 SG_LOG(SG_INPUT, SG_INFO, "Read properties for " <<
663 root.getStringValue("name"));
666 HUD_deque.erase( HUD_deque.begin(), HUD_deque.end()); // empty the HUD deque
669 SG_LOG(SG_INPUT, SG_INFO, "Reading Hud instruments");
671 const SGPropertyNode * instrument_group = root.getChild("instruments");
672 int nInstruments = instrument_group->nChildren();
674 for (int i = 0; i < nInstruments; i++) {
676 const SGPropertyNode * node = instrument_group->getChild(i);
678 SGPath path( globals->get_fg_root() );
679 path.append(node->getStringValue("path"));
681 SG_LOG(SG_INPUT, SG_INFO, "Reading Instrument "
687 SGPropertyNode root2;
689 readProperties(path.str(), &root2);
690 } catch (const sg_io_exception &e) {
691 string message = "Error reading HUD instrument: ";
692 message += e.getMessage();
694 message += e.getLocation().asString();
695 SG_LOG(SG_INPUT, SG_ALERT, message);
696 mkDialog(message.c_str());
699 readInstrument(&root2);
706 int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
712 SG_LOG( SG_COCKPIT, SG_INFO, "Initializing current aircraft HUD" );
715 fgGetString("/sim/hud/path", "Huds/Default/default.xml");
716 SGPath path(globals->get_fg_root());
717 path.append(hud_path);
719 ifstream input(path.c_str());
722 SG_LOG(SG_INPUT, SG_ALERT,
723 "Cannot read Hud configuration from " << path.str());
734 return 0; // For now. Later we may use this for an error code.
738 int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
743 SG_LOG( SG_COCKPIT, SG_INFO, "Initializing current aircraft HUD" );
745 SGPath path(globals->get_fg_root());
746 path.append("Huds/Minimal/default.xml");
749 ifstream input(path.c_str());
751 SG_LOG(SG_INPUT, SG_ALERT,
752 "Cannot read Hud configuration from " << path.str());
759 return 0; // For now. Later we may use this for an error code.
762 //$$$ End - added, Neetha, 28 Nov 2k
764 static int global_day_night_switch = DAY;
766 void HUD_masterswitch( bool incr )
768 if ( fgGetBool("/sim/hud/visibility") ) {
769 if ( global_day_night_switch == DAY ) {
770 global_day_night_switch = NIGHT;
772 fgSetBool("/sim/hud/visibility", false);
775 fgSetBool("/sim/hud/visibility", true);
776 global_day_night_switch = DAY;
780 void HUD_brightkey( bool incr_bright )
782 instr_item *pHUDInstr = HUD_deque[0];
783 int brightness = pHUDInstr->get_brightness();
785 if( fgGetBool("/sim/hud/visibility") ) {
790 brightness = BRT_BLACK;
794 brightness = BRT_LIGHT;
798 brightness = BRT_MEDIUM;
802 brightness = BRT_DARK;
806 brightness = BRT_BLACK;
812 brightness = BRT_MEDIUM;
816 brightness = BRT_DARK;
820 brightness = BRT_BLACK;
824 brightness = BRT_LIGHT;
828 fgSetBool("/sim/hud/visibility", false);
832 fgSetBool("/sim/hud/visibility", true);
835 pHUDInstr->SetBrightness( brightness );
839 #define fgAP_CLAMP(val,min,max) ( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) )
841 static puDialogBox *HUDalphaDialog;
842 static puText *HUDalphaText;
843 static puSlider *HUDalphaHS0;
844 //static puText *HUDtextText;
845 //static puSlider *HUDalphaHS1;
846 static char SliderText[2][ 8 ];
848 static void alpha_adj( puObject *hs ) {
851 hs-> getValue ( &val ) ;
852 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
853 // printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
854 hud_trans_alpha = val;
855 sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
856 HUDalphaText -> setLabel ( SliderText[ 0 ] ) ;
859 void fgHUDalphaAdjust( puObject * ) {
860 fgSetBool("/sim/hud/antialiased", true);
861 FG_PUSH_PUI_DIALOG( HUDalphaDialog );
864 static void goAwayHUDalphaAdjust (puObject *)
866 FG_POP_PUI_DIALOG( HUDalphaDialog );
869 static void cancelHUDalphaAdjust (puObject *)
871 fgSetBool("/sim/hud/antialiased", false);
872 FG_POP_PUI_DIALOG( HUDalphaDialog );
875 // Done once at system initialization
876 void fgHUDalphaInit( void ) {
878 // printf("fgHUDalphaInit\n");
879 #define HORIZONTAL FALSE
883 int DialogWidth = 240;
885 char Label[] = "HUD Adjuster";
888 int labelX = (DialogWidth / 2) -
889 (puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
894 int slider_width = 220;
895 int slider_title_x = 15;
896 int slider_value_x = 160;
897 float slider_delta = 0.05f;
899 puFont HUDalphaLegendFont;
900 puFont HUDalphaLabelFont;
901 puGetDefaultFonts ( &HUDalphaLegendFont, &HUDalphaLabelFont );
903 HUDalphaDialog = new puDialogBox ( DialogX, DialogY ); {
904 int horiz_slider_height = puGetStringHeight (HUDalphaLabelFont) +
905 puGetStringDescender (HUDalphaLabelFont) +
906 PUSTR_TGAP + PUSTR_BGAP + 5;
909 HUDalphaFrame = new puFrame ( 0, 0, DialogWidth,
911 * horiz_slider_height ); */
914 HUDalphaDialogMessage = new puText ( labelX,
916 * horiz_slider_height );
917 HUDalphaDialogMessage -> setDefaultValue ( Label );
918 HUDalphaDialogMessage -> getDefaultValue ( &s );
919 HUDalphaDialogMessage -> setLabel ( s );
921 HUDalphaHS0 = new puSlider ( slider_x, slider_y,
922 slider_width, HORIZONTAL ) ;
923 HUDalphaHS0-> setDelta ( slider_delta ) ;
924 HUDalphaHS0-> setValue ( hud_trans_alpha ) ;
925 HUDalphaHS0-> setCBMode ( PUSLIDER_DELTA ) ;
926 HUDalphaHS0-> setCallback ( alpha_adj ) ;
929 HUDalphaTitle = new puText ( slider_title_x, slider_y ) ;
930 HUDalphaTitle-> setDefaultValue ( "Alpha" ) ;
931 HUDalphaTitle-> getDefaultValue ( &s ) ;
932 HUDalphaTitle-> setLabel ( s ) ;
934 HUDalphaText = new puText ( slider_value_x, slider_y ) ;
935 sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
936 HUDalphaText-> setLabel ( SliderText[ 0 ] ) ;
939 HUDalphaOkButton = new puOneShot ( 10, 10, 60, 45 );
940 HUDalphaOkButton-> setLegend ( gui_msg_OK );
941 HUDalphaOkButton-> makeReturnDefault ( TRUE );
942 HUDalphaOkButton-> setCallback ( goAwayHUDalphaAdjust );
945 HUDalphaNoButton = new puOneShot ( 160, 10, 230, 45 );
946 HUDalphaNoButton-> setLegend ( gui_msg_CANCEL );
947 HUDalphaNoButton-> setCallback ( cancelHUDalphaAdjust );
949 FG_FINALIZE_PUI_DIALOG( HUDalphaDialog );
955 void fgHUDReshape(void) {
957 // this chunk of code is not necessarily thread safe if the
958 // compiler optimizer reorders these statements. Note that
959 // "delete ptr" does not set "ptr = NULL". We have to do that
961 fntRenderer *tmp = HUDtext;
966 HUD_TextSize = fgGetInt("/sim/startup/xsize") / 60;
968 HUDtext = new fntRenderer();
969 HUDtext -> setFont ( guiFntHandle ) ;
970 HUDtext -> setPointSize ( HUD_TextSize ) ;
971 HUD_TextList.setFont( HUDtext );
975 static void set_hud_color(float r, float g, float b) {
976 fgGetBool("/sim/hud/antialiased") ?
977 glColor4f(r,g,b,hud_trans_alpha) :
984 // Performs a once around the list of calls to instruments installed in
985 // the HUD object with requests for redraw. Kinda. It will when this is
988 void fgUpdateHUD( void ) {
990 static const float normal_aspect = float(640) / float(480);
991 // note: win_ratio is Y/X
992 float current_aspect = 1.0f/globals->get_current_view()->get_win_ratio();
993 if( current_aspect > normal_aspect ) {
994 float aspect_adjust = current_aspect / normal_aspect;
995 float adjust = 320.0f*aspect_adjust - 320.0f;
996 fgUpdateHUD( -adjust, 0.0f, 640.0f+adjust, 480.0f );
998 float aspect_adjust = normal_aspect / current_aspect;
999 float adjust = 240.0f*aspect_adjust - 240.0f;
1000 fgUpdateHUD( 0.0f, -adjust, 640.0f, 480.0f+adjust );
1004 void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
1005 GLfloat x_end, GLfloat y_end )
1008 // int day_night_sw = current_aircraft.controls->day_night_switch;
1009 int day_night_sw = global_day_night_switch;
1010 int hud_displays = HUD_deque.size();
1011 instr_item *pHUDInstr;
1012 // float line_width;
1014 if( !hud_displays ) { // Trust everyone, but ALWAYS cut the cards!
1018 HUD_TextList.erase();
1019 HUD_LineList.erase();
1020 // HUD_StippleLineList.erase();
1022 pHUDInstr = HUD_deque[0];
1023 brightness = pHUDInstr->get_brightness();
1024 // brightness = HUD_deque.at(0)->get_brightness();
1026 glMatrixMode(GL_PROJECTION);
1030 gluOrtho2D(x_start, x_end, y_start, y_end);
1031 glMatrixMode(GL_MODELVIEW);
1035 glDisable(GL_DEPTH_TEST);
1036 glDisable(GL_LIGHTING);
1038 static const SGPropertyNode * antialiased_node
1039 = fgGetNode("/sim/hud/antialiased");
1041 if( antialiased_node->getBoolValue() ) {
1042 glEnable(GL_LINE_SMOOTH);
1043 // glEnable(GL_BLEND);
1044 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1045 glHint(GL_LINE_SMOOTH_HINT,GL_DONT_CARE);
1046 // glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
1052 if( day_night_sw == DAY) {
1056 set_hud_color (0.1f, 0.9f, 0.1f);
1060 set_hud_color (0.1f, 0.7f, 0.0f);
1064 set_hud_color (0.0f, 0.6f, 0.0f);
1068 set_hud_color( 0.0f, 0.0f, 0.0f);
1072 set_hud_color (0.1f, 0.9f, 0.1f);
1075 if( day_night_sw == NIGHT) {
1079 set_hud_color (0.9f, 0.1f, 0.1f);
1083 set_hud_color (0.7f, 0.0f, 0.1f);
1087 set_hud_color (0.6f, 0.0f, 0.0f);
1091 set_hud_color( 0.0f, 0.0f, 0.0f);
1095 set_hud_color (0.6f, 0.0f, 0.0f);
1097 } else { // Just in case default
1098 set_hud_color (0.1f, 0.9f, 0.1f);
1102 deque < instr_item * > :: iterator current = HUD_deque.begin();
1103 deque < instr_item * > :: iterator last = HUD_deque.end();
1105 for ( ; current != last; ++current ) {
1106 pHUDInstr = *current;
1108 if( pHUDInstr->enabled()) {
1109 // fgPrintf( SG_COCKPIT, SG_DEBUG, "HUD Code %d Status %d\n",
1110 // hud->code, hud->status );
1116 char *gmt_str = get_formated_gmt_time();
1117 HUD_TextList.add( fgText(40, 10, gmt_str) );
1119 #ifdef FG_NETWORK_OLK
1120 if ( net_hud_display ) {
1127 // extern bool fgAPAltitudeEnabled( void );
1128 // extern bool fgAPHeadingEnabled( void );
1129 // extern bool fgAPWayPointEnabled( void );
1130 // extern char *fgAPget_TargetDistanceStr( void );
1131 // extern char *fgAPget_TargetHeadingStr( void );
1132 // extern char *fgAPget_TargetAltitudeStr( void );
1133 // extern char *fgAPget_TargetLatLonStr( void );
1136 // char scratch[128];
1137 // HUD_TextList.add( fgText( "AUTOPILOT", 20, apY) );
1139 if( current_autopilot->get_HeadingEnabled() ) {
1140 HUD_TextList.add( fgText( 40, apY,
1141 current_autopilot->get_TargetHeadingStr()) );
1144 if( current_autopilot->get_AltitudeEnabled() ) {
1145 HUD_TextList.add( fgText( 40, apY,
1146 current_autopilot->get_TargetAltitudeStr()) );
1149 if( current_autopilot->get_HeadingMode() ==
1150 FGAutopilot::FG_HEADING_WAYPOINT )
1153 wpstr = current_autopilot->get_TargetWP1Str();
1154 if ( strlen( wpstr ) ) {
1155 HUD_TextList.add( fgText( 40, apY, wpstr ) );
1158 wpstr = current_autopilot->get_TargetWP2Str();
1159 if ( strlen( wpstr ) ) {
1160 HUD_TextList.add( fgText( 40, apY, wpstr ) );
1163 wpstr = current_autopilot->get_TargetWP3Str();
1164 if ( strlen( wpstr ) ) {
1165 HUD_TextList.add( fgText( 40, apY, wpstr ) );
1170 HUD_TextList.draw();
1172 HUD_LineList.draw();
1174 // glEnable(GL_LINE_STIPPLE);
1175 // glLineStipple( 1, 0x00FF );
1176 // HUD_StippleLineList.draw();
1177 // glDisable(GL_LINE_STIPPLE);
1179 if( antialiased_node->getBoolValue() ) {
1180 // glDisable(GL_BLEND);
1181 glDisable(GL_LINE_SMOOTH);
1185 glEnable(GL_DEPTH_TEST);
1186 glEnable(GL_LIGHTING);
1187 glMatrixMode(GL_PROJECTION);
1189 glMatrixMode(GL_MODELVIEW);