]> git.mxchange.org Git - flightgear.git/blob - Main/options.cxx
Tweaks for building with native SGI compilers.
[flightgear.git] / Main / options.cxx
1 // options.cxx -- class to handle command line options
2 //
3 // Written by Curtis Olson, started April 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifdef HAVE_CONFIG_H
26 #  include <config.h>
27 #endif
28
29 #include <Include/compiler.h>
30
31 #include <math.h>            // rint()
32 #include <stdio.h>
33 #include <stdlib.h>          // atof(), atoi()
34 #include <string.h>
35
36 #include STL_STRING
37
38 #include <Debug/logstream.hxx>
39 #include <Misc/fgstream.hxx>
40 #include <FDM/flight.hxx>
41 #include <Include/fg_constants.h>
42 #include <Main/options.hxx>
43
44 #include "fg_serial.hxx"
45
46 FG_USING_STD(string);
47 FG_USING_NAMESPACE(std);
48
49
50 inline double
51 atof( const string& str )
52 {
53     return ::atof( str.c_str() );
54 }
55
56 inline int
57 atoi( const string& str )
58 {
59     return ::atoi( str.c_str() );
60 }
61
62 // Defined the shared options class here
63 fgOPTIONS current_options;
64
65
66 // Constructor
67 fgOPTIONS::fgOPTIONS() :
68     // starting longitude in degrees (west = -)
69     // starting latitude in degrees (south = -)
70
71     // Default initial position is Globe, AZ (P13)
72     lon(-110.6642444),
73     lat(  33.3528917),
74
75     // North of the city of Globe
76     // lon(-110.7),
77     // lat(  33.4),
78
79     // North of the city of Globe
80     // lon(-110.742578),
81     // lat(  33.507122),
82
83     // Near where I used to live in Globe, AZ
84     // lon(-110.766000),
85     // lat(  33.377778),
86
87     // 10125 Jewell St. NE
88     // lon(-93.15),
89     // lat( 45.15),
90
91     // Near KHSP (Hot Springs, VA)
92     // lon(-79.8338964 + 0.01),
93     // lat( 37.9514564 + 0.008),
94
95     // (SEZ) SEDONA airport
96     // lon(-111.7884614 + 0.01),
97     // lat(  34.8486289 - 0.015),
98
99     // Jim Brennon's Kingmont Observatory
100     // lon(-121.1131667),
101     // lat(  38.8293917),
102
103     // Huaras, Peru (S09d 31.871'  W077d 31.498')
104     // lon(-77.5249667),
105     // lat( -9.5311833),
106  
107     // Eclipse Watching w73.5 n10 (approx) 18:00 UT
108     // lon(-73.5),
109     // lat( 10.0),
110
111     // Timms Hill (WI)
112     // lon(-90.1953055556),
113     // lat( 45.4511388889),
114
115     // starting altitude in meters (this will be reset to ground level
116     // if it is lower than the terrain
117     altitude(-9999.0),
118
119     // Initial Orientation
120     heading(270.0),      // heading (yaw) angle in degress (Psi)
121     roll(0.0),           // roll angle in degrees (Phi)
122     pitch(0.424),        // pitch angle in degrees (Theta)
123
124     // Miscellaneous
125     game_mode(0),
126     splash_screen(1),
127     intro_music(1),
128     mouse_pointer(0),
129     pause(0),
130
131     // Features
132     hud_status(1),
133     panel_status(0),
134     sound(1),
135
136     // Flight Model options
137     flight_model(FGInterface::FG_LARCSIM),
138
139     // Rendering options
140     fog(FG_FOG_NICEST),  // nicest
141     fov(55.0),
142     fullscreen(0),
143     shading(1),
144     skyblend(1),
145     textures(1),
146     wireframe(0),
147     xsize(640),
148     ysize(480),
149
150     // Scenery options
151     tile_diameter(5),
152
153     // HUD options
154     units(FG_UNITS_FEET),
155     tris_or_culled(0),
156         
157     // Time options
158     time_offset(0)
159
160 {
161     // set initial values/defaults
162     char* envp = ::getenv( "FG_ROOT" );
163
164     if ( envp != NULL ) {
165         // fg_root could be anywhere, so default to environmental
166         // variable $FG_ROOT if it is set.
167         fg_root = envp;
168     } else {
169         // Otherwise, default to a random compiled in location if
170         // $FG_ROOT is not set.  This can still be overridden from the
171         // command line or a config file.
172
173 #if defined(WIN32)
174         fg_root = "\\FlightGear";
175 #else
176         fg_root = "/usr/local/lib/FlightGear";
177 #endif
178     }
179
180     airport_id = "";  // default airport id
181
182     // initialize port config string list
183     port_options_list.erase ( port_options_list.begin(), 
184                               port_options_list.end() );
185 }
186
187
188 double
189 fgOPTIONS::parse_time(const string& time_in) {
190     char *time_str, num[256];
191     double hours, minutes, seconds;
192     double result = 0.0;
193     int sign = 1;
194     int i;
195
196     time_str = (char *)time_in.c_str();
197
198     // printf("parse_time(): %s\n", time_str);
199
200     // check for sign
201     if ( strlen(time_str) ) {
202         if ( time_str[0] == '+' ) {
203             sign = 1;
204             time_str++;
205         } else if ( time_str[0] == '-' ) {
206             sign = -1;
207             time_str++;
208         }
209     }
210     // printf("sign = %d\n", sign);
211
212     // get hours
213     if ( strlen(time_str) ) {
214         i = 0;
215         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
216             num[i] = time_str[0];
217             time_str++;
218             i++;
219         }
220         if ( time_str[0] == ':' ) {
221             time_str++;
222         }
223         num[i] = '\0';
224         hours = atof(num);
225         // printf("hours = %.2lf\n", hours);
226
227         result += hours;
228     }
229
230     // get minutes
231     if ( strlen(time_str) ) {
232         i = 0;
233         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
234             num[i] = time_str[0];
235             time_str++;
236             i++;
237         }
238         if ( time_str[0] == ':' ) {
239             time_str++;
240         }
241         num[i] = '\0';
242         minutes = atof(num);
243         // printf("minutes = %.2lf\n", minutes);
244
245         result += minutes / 60.0;
246     }
247
248     // get seconds
249     if ( strlen(time_str) ) {
250         i = 0;
251         while ( (time_str[0] != ':') && (time_str[0] != '\0') ) {
252             num[i] = time_str[0];
253             time_str++;
254             i++;
255         }
256         num[i] = '\0';
257         seconds = atof(num);
258         // printf("seconds = %.2lf\n", seconds);
259
260         result += seconds / 3600.0;
261     }
262
263     return(sign * result);
264 }
265
266
267 // parse degree in the form of [+/-]hhh:mm:ss
268 double
269 fgOPTIONS::parse_degree( const string& degree_str) {
270     double result = parse_time( degree_str );
271
272     // printf("Degree = %.4f\n", result);
273
274     return(result);
275 }
276
277
278 // parse time offset command line option
279 int
280 fgOPTIONS::parse_time_offset( const string& time_str) {
281     int result;
282
283     // printf("time offset = %s\n", time_str);
284
285 #ifdef HAVE_RINT
286     result = (int)rint(parse_time(time_str) * 3600.0);
287 #else
288     result = (int)(parse_time(time_str) * 3600.0);
289 #endif
290
291     // printf("parse_time_offset(): %d\n", result);
292
293     return( result );
294 }
295
296
297 // Parse --tile-diameter=n type option 
298
299 int
300 fgOPTIONS::parse_tile_radius( const string& arg ) {
301     int radius = atoi( arg );
302
303     if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
304     if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
305
306     // printf("parse_tile_radius(): radius = %d\n", radius);
307
308     return(radius);
309 }
310
311
312 // Parse --fdm=abcdefg type option 
313 int
314 fgOPTIONS::parse_fdm( const string& fm ) {
315     // printf("fdm = %s\n", fm);
316
317     if ( fm == "slew" ) {
318         return FGInterface::FG_SLEW;
319     } else if ( fm == "jsb" ) {
320         return FGInterface::FG_JSBSIM;
321     } else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
322         return FGInterface::FG_LARCSIM;
323     } else if ( fm == "external" ) {
324         return FGInterface::FG_EXTERNAL;
325     } else {
326         FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
327         exit(-1);
328     }
329
330     // we'll never get here, but it makes the compiler happy.
331     return -1;
332 }
333
334
335 // Parse --fov=x.xx type option 
336 double
337 fgOPTIONS::parse_fov( const string& arg ) {
338     double fov = atof(arg);
339
340     if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
341     if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
342
343     // printf("parse_fov(): result = %.4f\n", fov);
344
345     return(fov);
346 }
347
348
349 // Parse serial port option --serial=/dev/ttyS1,nmea,4800,out
350 //
351 // Format is "--serial=device,format,baud,direction" where
352 // 
353 //  device = OS device name to be open()'ed
354 //  format = {nmea, fgfs}
355 //  baud = {300, 1200, 2400, ..., 230400}
356 //  direction = {in, out, bi}
357
358 bool 
359 fgOPTIONS::parse_serial( const string& serial_str ) {
360     string::size_type pos;
361
362     // cout << "Serial string = " << serial_str << endl;
363
364     // a flailing attempt to see if the port config string has a
365     // chance at being valid
366     pos = serial_str.find(",");
367     if ( pos == string::npos ) {
368         FG_LOG( FG_GENERAL, FG_ALERT, 
369                 "Malformed serial port configure string" );
370         return false;
371     }
372     
373     port_options_list.push_back( serial_str );
374
375     return true;
376 }
377
378
379 // Parse a single option
380 int fgOPTIONS::parse_option( const string& arg ) {
381     // General Options
382     if ( (arg == "--help") || (arg == "-h") ) {
383         // help/usage request
384         return(FG_OPTIONS_HELP);
385     } else if ( arg == "--disable-game-mode") {
386         game_mode = false;
387     } else if ( arg == "--enable-game-mode" ) {
388         game_mode = true;
389     } else if ( arg == "--disable-splash-screen" ) {
390         splash_screen = false;
391     } else if ( arg == "--enable-splash-screen" ) {
392         splash_screen = true;
393     } else if ( arg == "--disable-intro-music" ) {
394         intro_music = false;
395     } else if ( arg == "--enable-intro-music" ) {
396         intro_music = true;
397     } else if ( arg == "--disable-mouse-pointer" ) {
398         mouse_pointer = 1;
399     } else if ( arg == "--enable-mouse-pointer" ) {
400         mouse_pointer = 2;
401     } else if ( arg == "--disable-pause" ) {
402         pause = false;  
403     } else if ( arg == "--enable-pause" ) {
404         pause = true;   
405     } else if ( arg == "--disable-hud" ) {
406         hud_status = false;     
407     } else if ( arg == "--enable-hud" ) {
408         hud_status = true;      
409     } else if ( arg == "--disable-panel" ) {
410         panel_status = false;
411     } else if ( arg == "--enable-panel" ) {
412         panel_status = true;
413     } else if ( arg == "--disable-sound" ) {
414         sound = false;
415     } else if ( arg == "--enable-sound" ) {
416         sound = true;
417     } else if ( arg.find( "--airport-id=") != string::npos ) {
418         airport_id = arg.substr( 13 );
419     } else if ( arg.find( "--lon=" ) != string::npos ) {
420         lon = parse_degree( arg.substr(6) );
421     } else if ( arg.find( "--lat=" ) != string::npos ) {
422         lat = parse_degree( arg.substr(6) );
423     } else if ( arg.find( "--altitude=" ) != string::npos ) {
424         if ( units == FG_UNITS_FEET ) {
425             altitude = atof( arg.substr(11) ) * FEET_TO_METER;
426         } else {
427             altitude = atof( arg.substr(11) );
428         }
429     } else if ( arg.find( "--heading=" ) != string::npos ) {
430         heading = atof( arg.substr(10) );
431     } else if ( arg.find( "--roll=" ) != string::npos ) {
432         roll = atof( arg.substr(7) );
433     } else if ( arg.find( "--pitch=" ) != string::npos ) {
434         pitch = atof( arg.substr(8) );
435     } else if ( arg.find( "--fg-root=" ) != string::npos ) {
436         fg_root = arg.substr( 10 );
437     } else if ( arg.find( "--fdm=" ) != string::npos ) {
438         flight_model = parse_fdm( arg.substr(6) );
439     } else if ( arg == "--fog-disable" ) {
440         fog = FG_FOG_DISABLED;  
441     } else if ( arg == "--fog-fastest" ) {
442         fog = FG_FOG_FASTEST;   
443     } else if ( arg == "--fog-nicest" ) {
444         fog = FG_FOG_NICEST;    
445     } else if ( arg.find( "--fov=" ) != string::npos ) {
446         fov = parse_fov( arg.substr(6) );
447     } else if ( arg == "--disable-fullscreen" ) {
448         fullscreen = false;     
449     } else if ( arg== "--enable-fullscreen") {
450         fullscreen = true;      
451     } else if ( arg == "--shading-flat") {
452         shading = 0;    
453     } else if ( arg == "--shading-smooth") {
454         shading = 1;    
455     } else if ( arg == "--disable-skyblend") {
456         skyblend = false;       
457     } else if ( arg== "--enable-skyblend" ) {
458         skyblend = true;        
459     } else if ( arg == "--disable-textures" ) {
460         textures = false;       
461     } else if ( arg == "--enable-textures" ) {
462         textures = true;
463     } else if ( arg == "--disable-wireframe" ) {
464         wireframe = false;      
465     } else if ( arg == "--enable-wireframe" ) {
466         wireframe = true;
467     } else if ( arg.find( "--geometry=" ) != string::npos ) {
468         string geometry = arg.substr( 11 );
469         if ( geometry == "640x480" ) {
470             xsize = 640;
471             ysize = 480;
472         } else if ( geometry == "800x600" ) {
473             xsize = 800;
474             ysize = 600;
475         } else if ( geometry == "1024x768" ) {
476             xsize = 1024;
477             ysize = 768;
478         } else {
479             FG_LOG( FG_GENERAL, FG_ALERT, "Unknown geometry: " << geometry );
480             exit(-1);
481         }
482     } else if ( arg == "--units-feet" ) {
483         units = FG_UNITS_FEET;  
484     } else if ( arg == "--units-meters" ) {
485         units = FG_UNITS_METERS;        
486     } else if ( arg.find( "--tile-radius=" ) != string::npos ) {
487         tile_radius = parse_tile_radius( arg.substr(14) );
488         tile_diameter = tile_radius * 2 + 1;
489     } else if ( arg.find( "--time-offset=" ) != string::npos ) {
490         time_offset = parse_time_offset( (arg.substr(14)) );
491     } else if ( arg == "--hud-tris" ) {
492         tris_or_culled = 0;     
493     } else if ( arg == "--hud-culled" ) {
494         tris_or_culled = 1;
495     } else if ( arg.find( "--serial=" ) != string::npos ) {
496         parse_serial( arg.substr(9) );
497     } else {
498         FG_LOG( FG_GENERAL, FG_ALERT, "Unknown option '" << arg << "'" );
499         return FG_OPTIONS_ERROR;
500     }
501     
502     return FG_OPTIONS_OK;
503 }
504
505
506 // Parse the command line options
507 int fgOPTIONS::parse_command_line( int argc, char **argv ) {
508     int i = 1;
509     int result;
510
511     FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
512
513     while ( i < argc ) {
514         FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
515
516         result = parse_option(argv[i]);
517         if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
518             return(result);
519         }
520
521         i++;
522     }
523     
524     return(FG_OPTIONS_OK);
525 }
526
527
528 // Parse config file options
529 int fgOPTIONS::parse_config_file( const string& path ) {
530     fg_gzifstream in( path );
531     if ( !in )
532         return(FG_OPTIONS_ERROR);
533
534     FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
535
536     in >> skipcomment;
537     while ( !in.eof() )
538     {
539         string line;
540         getline( in, line );
541
542         if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
543             FG_LOG( FG_GENERAL, FG_ALERT, 
544                     "Config file parse error: " << path << " '" 
545                     << line << "'" );
546             exit(-1);
547         }
548         in >> skipcomment;
549     }
550
551     return FG_OPTIONS_OK;
552 }
553
554
555 // Print usage message
556 void fgOPTIONS::usage ( void ) {
557     printf("Usage: fg [ options ... ]\n");
558     printf("\n");
559
560     printf("General Options:\n");
561     printf("\t--help -h:  print usage\n");
562     printf("\t--fg-root=path:  specify the root path for all the data files\n");
563     printf("\t--disable-game-mode:  disable full-screen game mode\n");
564     printf("\t--enable-game-mode:  enable full-screen game mode\n");
565     printf("\t--disable-splash-screen:  disable splash screen\n");
566     printf("\t--enable-splash-screen:  enable splash screen\n");
567     printf("\t--disable-intro-music:  disable introduction music\n");
568     printf("\t--enable-intro-music:  enable introduction music\n");
569     printf("\t--disable-mouse-pointer:  disable extra mouse pointer\n");
570     printf("\t--enable-mouse-pointer:  enable extra mouse pointer (i.e. for\n");
571     printf("\t\tfull screen voodoo/voodoo-II based cards.)\n");
572     printf("\t--disable-pause:  start out in an active state\n");
573     printf("\t--enable-pause:  start out in a paused state\n");
574     printf("\n");
575
576     printf("Features:\n");
577     printf("\t--disable-hud:  disable heads up display\n");
578     printf("\t--enable-hud:  enable heads up display\n");
579     printf("\t--disable-panel:  disable instrument panel\n");
580     printf("\t--enable-panel:  enable instrumetn panel\n");
581     printf("\t--disable-sound:  disable sound effects\n");
582     printf("\t--enable-sound:  enable sound effects\n");
583     printf("\n");
584  
585     printf("Flight Model:\n");
586     printf("\t--fdm=abcd:  one of slew, jsb, larcsim, or external\n");
587     printf("\n");
588
589     printf("Initial Position and Orientation:\n");
590     printf("\t--airport-id=ABCD:  specify starting postion by airport id\n");
591     printf("\t--lon=degrees:  starting longitude in degrees (west = -)\n");
592     printf("\t--lat=degrees:  starting latitude in degrees (south = -)\n");
593     printf("\t--altitude=feet:  starting altitude in feet\n");
594     printf("\t\t(unless --units-meters specified\n");
595     printf("\t--heading=degrees:  heading (yaw) angle in degress (Psi)\n");
596     printf("\t--roll=degrees:  roll angle in degrees (Phi)\n");
597     printf("\t--pitch=degrees:  pitch angle in degrees (Theta)\n");
598     printf("\n");
599
600     printf("Rendering Options:\n");
601     printf("\t--fog-disable:  disable fog/haze\n");
602     printf("\t--fog-fastest:  enable fastest fog/haze\n");
603     printf("\t--fog-nicest:  enable nicest fog/haze\n");
604     printf("\t--fov=xx.x:  specify initial field of view angle in degrees\n");
605     printf("\t--disable-fullscreen:  disable fullscreen mode\n");
606     printf("\t--enable-fullscreen:  enable fullscreen mode\n");
607     printf("\t--shading-flat:  enable flat shading\n");
608     printf("\t--shading-smooth:  enable smooth shading\n");
609     printf("\t--disable-skyblend:  disable sky blending\n");
610     printf("\t--enable-skyblend:  enable sky blending\n");
611     printf("\t--disable-textures:  disable textures\n");
612     printf("\t--enable-textures:  enable textures\n");
613     printf("\t--disable-wireframe:  disable wireframe drawing mode\n");
614     printf("\t--enable-wireframe:  enable wireframe drawing mode\n");
615     printf("\t--geometry=WWWxHHH:  window geometry: 640x480, 800x600, etc.\n");
616     printf("\n");
617
618     printf("Scenery Options:\n");
619     printf("\t--tile-radius=n:  specify tile radius, must be 1 - 4\n");
620     printf("\n");
621
622     printf("Hud Options:\n");
623     printf("\t--units-feet:  Hud displays units in feet\n");
624     printf("\t--units-meters:  Hud displays units in meters\n");
625     printf("\t--hud-tris:  Hud displays number of triangles rendered\n");
626     printf("\t--hud-culled:  Hud displays percentage of triangles culled\n");
627     printf("\n");
628         
629     printf("Time Options:\n");
630     printf("\t--time-offset=[+-]hh:mm:ss:  offset local time by this amount\n");
631 }
632
633
634 // Destructor
635 fgOPTIONS::~fgOPTIONS( void ) {
636 }
637
638
639 // $Log$
640 // Revision 1.41  1999/03/02 01:03:17  curt
641 // Tweaks for building with native SGI compilers.
642 //
643 // Revision 1.40  1999/02/26 22:09:51  curt
644 // Added initial support for native SGI compilers.
645 //
646 // Revision 1.39  1999/02/05 21:29:12  curt
647 // Modifications to incorporate Jon S. Berndts flight model code.
648 //
649 // Revision 1.38  1999/02/01 21:33:35  curt
650 // Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
651 // Jon accepted my offer to do this and thought it was a good idea.
652 //
653 // Revision 1.37  1999/01/19 20:57:05  curt
654 // MacOS portability changes contributed by "Robert Puyol" <puyol@abvent.fr>
655 //
656 // Revision 1.36  1999/01/07 20:25:10  curt
657 // Updated struct fgGENERAL to class FGGeneral.
658 //
659 // Revision 1.35  1998/12/06 14:52:57  curt
660 // Fixed a problem with the initial starting altitude.  "v->abs_view_pos" wasn't
661 // being calculated correctly at the beginning causing the first terrain
662 // intersection to fail, returning a ground altitude of zero, causing the plane
663 // to free fall for one frame, until the ground altitude was corrected, but now
664 // being under the ground we got a big bounce and the plane always ended up
665 // upside down.
666 //
667 // Revision 1.34  1998/12/05 15:54:22  curt
668 // Renamed class fgFLIGHT to class FGState as per request by JSB.
669 //
670 // Revision 1.33  1998/12/04 01:30:44  curt
671 // Added support for the External flight model.
672 //
673 // Revision 1.32  1998/11/25 01:34:00  curt
674 // Support for an arbitrary number of serial ports.
675 //
676 // Revision 1.31  1998/11/23 21:49:04  curt
677 // Borland portability tweaks.
678 //
679 // Revision 1.30  1998/11/16 14:00:02  curt
680 // Added pow() macro bug work around.
681 // Added support for starting FGFS at various resolutions.
682 // Added some initial serial port support.
683 // Specify default log levels in main().
684 //
685 // Revision 1.29  1998/11/06 21:18:12  curt
686 // Converted to new logstream debugging facility.  This allows release
687 // builds with no messages at all (and no performance impact) by using
688 // the -DFG_NDEBUG flag.
689 //
690 // Revision 1.28  1998/11/06 14:47:03  curt
691 // Changes to track Bernie's updates to fgstream.
692 //
693 // Revision 1.27  1998/11/02 23:04:04  curt
694 // HUD units now display in feet by default with meters being a command line
695 // option.
696 //
697 // Revision 1.26  1998/10/17 01:34:24  curt
698 // C++ ifying ...
699 //
700 // Revision 1.25  1998/09/15 02:09:27  curt
701 // Include/fg_callback.hxx
702 //   Moved code inline to stop g++ 2.7 from complaining.
703 //
704 // Simulator/Time/event.[ch]xx
705 //   Changed return type of fgEVENT::printStat().  void caused g++ 2.7 to
706 //   complain bitterly.
707 //
708 // Minor bugfix and changes.
709 //
710 // Simulator/Main/GLUTmain.cxx
711 //   Added missing type to idle_state definition - eliminates a warning.
712 //
713 // Simulator/Main/fg_init.cxx
714 //   Changes to airport lookup.
715 //
716 // Simulator/Main/options.cxx
717 //   Uses fg_gzifstream when loading config file.
718 //
719 // Revision 1.24  1998/09/08 15:04:33  curt
720 // Optimizations by Norman Vine.
721 //
722 // Revision 1.23  1998/08/27 17:02:07  curt
723 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
724 // - use strings for fg_root and airport_id and added methods to return
725 //   them as strings,
726 // - inlined all access methods,
727 // - made the parsing functions private methods,
728 // - deleted some unused functions.
729 // - propogated some of these changes out a bit further.
730 //
731 // Revision 1.22  1998/08/24 20:11:13  curt
732 // Added i/I to toggle full vs. minimal HUD.
733 // Added a --hud-tris vs --hud-culled option.
734 // Moved options accessor funtions to options.hxx.
735 //
736 // Revision 1.21  1998/08/20 15:10:34  curt
737 // Added GameGLUT support.
738 //
739 // Revision 1.20  1998/07/30 23:48:28  curt
740 // Output position & orientation when pausing.
741 // Eliminated libtool use.
742 // Added options to specify initial position and orientation.
743 // Changed default fov to 55 degrees.
744 // Added command line option to start in paused or unpaused state.
745 //
746 // Revision 1.19  1998/07/27 18:41:25  curt
747 // Added a pause command "p"
748 // Fixed some initialization order problems between pui and glut.
749 // Added an --enable/disable-sound option.
750 //
751 // Revision 1.18  1998/07/22 01:27:03  curt
752 // Strip out \r when parsing config file in case we are on a windoze system.
753 //
754 // Revision 1.17  1998/07/16 17:33:38  curt
755 // "H" / "h" now control hud brightness as well with off being one of the
756 //   states.
757 // Better checking for xmesa/fx 3dfx fullscreen/window support for deciding
758 //   whether or not to build in the feature.
759 // Translucent menu support.
760 // HAVE_AUDIO_SUPPORT -> ENABLE_AUDIO_SUPPORT
761 // Use fork() / wait() for playing mp3 init music in background under unix.
762 // Changed default tile diameter to 5.
763 //
764 // Revision 1.16  1998/07/13 21:01:39  curt
765 // Wrote access functions for current fgOPTIONS.
766 //
767 // Revision 1.15  1998/07/06 21:34:19  curt
768 // Added an enable/disable splash screen option.
769 // Added an enable/disable intro music option.
770 // Added an enable/disable instrument panel option.
771 // Added an enable/disable mouse pointer option.
772 // Added using namespace std for compilers that support this.
773 //
774 // Revision 1.14  1998/07/04 00:52:26  curt
775 // Add my own version of gluLookAt() (which is nearly identical to the
776 // Mesa/glu version.)  But, by calculating the Model View matrix our selves
777 // we can save this matrix without having to read it back in from the video
778 // card.  This hopefully allows us to save a few cpu cycles when rendering
779 // out the fragments because we can just use glLoadMatrixd() with the
780 // precalculated matrix for each tile rather than doing a push(), translate(),
781 // pop() for every fragment.
782 //
783 // Panel status defaults to off for now until it gets a bit more developed.
784 //
785 // Extract OpenGL driver info on initialization.
786 //
787 // Revision 1.13  1998/06/27 16:54:34  curt
788 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
789 // Don't change the view port when displaying the panel.
790 //
791 // Revision 1.12  1998/06/17 21:35:13  curt
792 // Refined conditional audio support compilation.
793 // Moved texture parameter setup calls to ../Scenery/materials.cxx
794 // #include <string.h> before various STL includes.
795 // Make HUD default state be enabled.
796 //
797 // Revision 1.11  1998/06/13 00:40:33  curt
798 // Tweaked fog command line options.
799 //
800 // Revision 1.10  1998/05/16 13:08:36  curt
801 // C++ - ified views.[ch]xx
802 // Shuffled some additional view parameters into the fgVIEW class.
803 // Changed tile-radius to tile-diameter because it is a much better
804 //   name.
805 // Added a WORLD_TO_EYE transformation to views.cxx.  This allows us
806 //  to transform world space to eye space for view frustum culling.
807 //
808 // Revision 1.9  1998/05/13 18:29:59  curt
809 // Added a keyboard binding to dynamically adjust field of view.
810 // Added a command line option to specify fov.
811 // Adjusted terrain color.
812 // Root path info moved to fgOPTIONS.
813 // Added ability to parse options out of a config file.
814 //
815 // Revision 1.8  1998/05/07 23:14:16  curt
816 // Added "D" key binding to set autopilot heading.
817 // Made frame rate calculation average out over last 10 frames.
818 // Borland C++ floating point exception workaround.
819 // Added a --tile-radius=n option.
820 //
821 // Revision 1.7  1998/05/06 03:16:25  curt
822 // Added an averaged global frame rate counter.
823 // Added an option to control tile radius.
824 //
825 // Revision 1.6  1998/05/03 00:47:32  curt
826 // Added an option to enable/disable full-screen mode.
827 //
828 // Revision 1.5  1998/04/30 12:34:19  curt
829 // Added command line rendering options:
830 //   enable/disable fog/haze
831 //   specify smooth/flat shading
832 //   disable sky blending and just use a solid color
833 //   enable wireframe drawing mode
834 //
835 // Revision 1.4  1998/04/28 01:20:22  curt
836 // Type-ified fgTIME and fgVIEW.
837 // Added a command line option to disable textures.
838 //
839 // Revision 1.3  1998/04/26 05:01:19  curt
840 // Added an rint() / HAVE_RINT check.
841 //
842 // Revision 1.2  1998/04/25 15:11:12  curt
843 // Added an command line option to set starting position based on airport ID.
844 //
845 // Revision 1.1  1998/04/24 00:49:21  curt
846 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
847 // Trying out some different option parsing code.
848 // Some code reorganization.
849 //
850 //