]> git.mxchange.org Git - flightgear.git/blob - Main/fg_init.cxx
Removed unused variables.
[flightgear.git] / Main / fg_init.cxx
1 //
2 // fg_init.cxx -- Flight Gear top level initialization routines
3 //
4 // Written by Curtis Olson, started August 1997.
5 //
6 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 //
23 // $Id$
24 // (Log is kept at end of this file)
25
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <stdio.h>
32 #include <stdlib.h>
33
34 // work around a stdc++ lib bug in some versions of linux, but doesn't
35 // seem to hurt to have this here for all versions of Linux.
36 #ifdef linux
37 #  define _G_NO_EXTERN_TEMPLATES
38 #endif
39
40 #include <string>
41
42 #include <Include/fg_constants.h>
43
44 #include <Aircraft/aircraft.hxx>
45 #include <Airports/simple.hxx>
46 #include <Astro/sky.hxx>
47 #include <Astro/stars.hxx>
48 #include <Astro/solarsystem.hxx>
49 #include <Autopilot/autopilot.hxx>
50 #include <Cockpit/cockpit.hxx>
51 #include <Debug/logstream.hxx>
52 #include <Joystick/joystick.hxx>
53 #include <Math/fg_geodesy.hxx>
54 #include <Math/fg_random.h>
55 #include <Math/point3d.hxx>
56 #include <Math/polar3d.hxx>
57 #include <Scenery/scenery.hxx>
58 #include <Scenery/tilemgr.hxx>
59 #include <Time/event.hxx>
60 #include <Time/fg_time.hxx>
61 #include <Time/light.hxx>
62 #include <Time/sunpos.hxx>
63 #include <Weather/weather.hxx>
64
65 #include "fg_init.hxx"
66 #include "options.hxx"
67 #include "views.hxx"
68
69
70 extern const char *default_root;
71
72
73 // Set initial position and orientation
74 int fgInitPosition( void ) {
75     string id;
76     FGState *f;
77
78     f = current_aircraft.fdm_state;
79
80     id = current_options.get_airport_id();
81     if ( id.length() ) {
82         // set initial position from airport id
83
84         fgAIRPORTS airports;
85         fgAIRPORT a;
86
87         FG_LOG( FG_GENERAL, FG_INFO, 
88                 "Attempting to set starting position from airport code "
89                 << id );
90
91         airports.load("apt_simple");
92         if ( ! airports.search( id, &a ) ) {
93             FG_LOG( FG_GENERAL, FG_ALERT, 
94                     "Failed to find " << id << " in database." );
95             exit(-1);
96         } else {
97             f->set_Longitude( a.longitude * DEG_TO_RAD );
98             f->set_Latitude( a.latitude * DEG_TO_RAD );
99         }
100     } else {
101         // set initial position from default or command line coordinates
102
103         f->set_Longitude( current_options.get_lon() * DEG_TO_RAD );
104         f->set_Latitude( current_options.get_lat() * DEG_TO_RAD );
105     }
106     FG_LOG( FG_GENERAL, FG_INFO, 
107             "starting altitude is = " << current_options.get_altitude() );
108
109     f->set_Altitude( current_options.get_altitude() * METER_TO_FEET );
110     fgFDMSetGroundElevation( current_options.get_flight_model(),
111                              (f->get_Altitude() - 3.758099) * FEET_TO_METER );
112
113     FG_LOG( FG_GENERAL, FG_INFO,
114             "Initial position is: ("
115             << (f->get_Longitude() * RAD_TO_DEG) << ", " 
116             << (f->get_Latitude() * RAD_TO_DEG) << ", " 
117             << (f->get_Altitude() * FEET_TO_METER) << ")" );
118
119     return(1);
120 }
121
122
123 // General house keeping initializations
124 int fgInitGeneral( void ) {
125     string root;
126     // int i;
127
128     FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
129     FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
130
131     root = current_options.get_fg_root();
132     if ( ! root.length() ) {
133         // No root path set? Then bail ...
134         FG_LOG( FG_GENERAL, FG_ALERT, 
135                 "Cannot continue without environment variable FG_ROOT"
136                 << "being defined." );
137         exit(-1);
138     }
139     FG_LOG( FG_GENERAL, FG_INFO, "FG_ROOT = " << root << endl );
140
141     // prime the frame rate counter pump
142     // for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) {
143     //    general.frames[i] = 0.0;
144     // }
145
146     return ( 1 ); 
147 }
148
149
150 // This is the top level init routine which calls all the other
151 // initialization routines.  If you are adding a subsystem to flight
152 // gear, its initialization call should located in this routine.
153 // Returns non-zero if a problem encountered.
154 int fgInitSubsystems( void )
155 {
156     FGState *f; // assigned later
157     fgLIGHT *l = &cur_light_params;
158     fgTIME *t = &cur_time_params;
159     FGView *v = &current_view;
160
161     FG_LOG( FG_GENERAL, FG_INFO, "Initialize Subsystems");
162     FG_LOG( FG_GENERAL, FG_INFO, "========== ==========");
163
164     // seed the random number generater
165     fg_srandom();
166
167     // allocates structures so must happen before any of the flight
168     // model or control parameters are set
169     fgAircraftInit();   // In the future this might not be the case.
170     f = current_aircraft.fdm_state;
171
172     // set the initial position
173     fgInitPosition();
174
175     // Initialize the Scenery Management subsystem
176     if ( fgSceneryInit() ) {
177         // Scenery initialized ok.
178     } else {
179         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Scenery initialization!" );
180         exit(-1);
181     }
182
183     if( fgTileMgrInit() ) {
184         // Load the local scenery data
185         fgTileMgrUpdate();
186     } else {
187         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
188         exit(-1);
189     }
190
191     FG_LOG( FG_GENERAL, FG_DEBUG, 
192             "Current terrain elevation after tile mgr init " << 
193             scenery.cur_elev );
194
195     // Calculate ground elevation at starting point (we didn't have
196     // tmp_abs_view_pos calculated when fgTileMgrUpdate() was called above
197     //
198     // calculalate a cartesian point somewhere along the line between
199     // the center of the earth and our view position.  Doesn't have to
200     // be the exact elevation (this is good because we don't know it
201     // yet :-)
202
203     // now handled inside of the fgTileMgrUpdate()
204
205     /*
206     geod_pos = Point3D( f->get_Longitude(), f->get_Latitude(), 0.0);
207     tmp_abs_view_pos = fgGeodToCart(geod_pos);
208
209     FG_LOG( FG_GENERAL, FG_DEBUG, 
210             "Initial abs_view_pos = " << tmp_abs_view_pos );
211     scenery.cur_elev = 
212         fgTileMgrCurElev( f->get_Longitude(), f->get_Latitude(), 
213                           tmp_abs_view_pos );
214     FG_LOG( FG_GENERAL, FG_DEBUG, 
215             "Altitude after update " << scenery.cur_elev );
216     */
217
218     fgFDMSetGroundElevation( current_options.get_flight_model(), 
219                              scenery.cur_elev );
220
221     // Reset our altitude if we are below ground
222     FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << f->get_Altitude() );
223     FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " << 
224             f->get_Runway_altitude() );
225
226     if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
227         f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
228     }
229
230     FG_LOG( FG_GENERAL, FG_INFO,
231             "Updated position (after elevation adj): ("
232             << (f->get_Latitude() * RAD_TO_DEG) << ", " 
233             << (f->get_Longitude() * RAD_TO_DEG) << ", " 
234             << (f->get_Altitude() * FEET_TO_METER) << ")" );
235
236     // We need to calculate a few more values here that would normally
237     // be calculated by the FDM so that the v->UpdateViewMath()
238     // routine doesn't get hosed.
239
240     double sea_level_radius_meters;
241     double lat_geoc;
242     // Set the FG variables first
243     fgGeodToGeoc( f->get_Latitude(), f->get_Altitude(), 
244                   &sea_level_radius_meters, &lat_geoc);
245     f->set_Geocentric_Position( lat_geoc, f->get_Longitude(), 
246                                 f->get_Altitude() + 
247                                 (sea_level_radius_meters * METER_TO_FEET) );
248     f->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
249
250     // The following section sets up the flight model EOM parameters
251     // and should really be read in from one or more files.
252
253     // Initial Velocity
254     f->set_Velocities_Local( 0.0, 0.0, 0.0 );
255
256     // Initial Orientation
257     f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
258                          current_options.get_pitch() * DEG_TO_RAD,
259                          current_options.get_heading() * DEG_TO_RAD );
260
261     // Initial Angular Body rates
262     f->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
263
264     f->set_Earth_position_angle( 0.0 );
265
266     // Mass properties and geometry values
267     f->set_Inertias( 8.547270E+01, 
268                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
269
270     // CG position w.r.t. ref. point
271     f->set_CG_Position( 0.0, 0.0, 0.0 );
272
273     // Initialize the event manager
274     global_events.Init();
275
276     // Output event stats every 60 seconds
277     global_events.Register( "fgEVENT_MGR::PrintStats()",
278                             fgMethodCallback<fgEVENT_MGR>( &global_events,
279                                                    &fgEVENT_MGR::PrintStats),
280                             fgEVENT::FG_EVENT_READY, 60000 );
281
282     // Initialize the time dependent variables
283     fgTimeInit(t);
284     fgTimeUpdate(f, t);
285
286     // Initialize view parameters
287     FG_LOG( FG_GENERAL, FG_DEBUG, "Before v->init()");
288     v->Init();
289     FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()");
290     v->UpdateViewMath(f);
291     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << v->get_abs_view_pos());
292     v->UpdateWorldToEye(f);
293
294     // Build the solar system
295     //fgSolarSystemInit(*t);
296     FG_LOG(FG_GENERAL, FG_INFO, "Building SolarSystem");
297     SolarSystem::theSolarSystem = new SolarSystem(t);
298
299     // Initialize the Stars subsystem
300     if( fgStarsInit() ) {
301         // Stars initialized ok.
302     } else {
303         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Stars initialization!" );
304         exit(-1);
305     }
306
307     // Initialize the planetary subsystem
308     // global_events.Register( "fgPlanetsInit()", fgPlanetsInit, 
309     //                      fgEVENT::FG_EVENT_READY, 600000);
310
311     // Initialize the sun's position 
312     // global_events.Register( "fgSunInit()", fgSunInit, 
313     //                      fgEVENT::FG_EVENT_READY, 30000 );
314
315     // Intialize the moon's position
316     // global_events.Register( "fgMoonInit()", fgMoonInit, 
317     //                      fgEVENT::FG_EVENT_READY, 600000 );
318
319     // register the periodic update of Sun, moon, and planets
320     global_events.Register( "ssolsysUpdate", solarSystemRebuild,
321                             fgEVENT::FG_EVENT_READY, 600000);
322     
323     // fgUpdateSunPos() needs a few position and view parameters set
324     // so it can calculate local relative sun angle and a few other
325     // things for correctly orienting the sky.
326     fgUpdateSunPos();
327     global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
328                             fgEVENT::FG_EVENT_READY, 60000);
329
330     // Initialize Lighting interpolation tables
331     l->Init();
332
333     // update the lighting parameters (based on sun angle)
334     global_events.Register( "fgLight::Update()",
335                             fgMethodCallback<fgLIGHT>( &cur_light_params,
336                                                        &fgLIGHT::Update),
337                             fgEVENT::FG_EVENT_READY, 30000 );
338
339     // Initialize the weather modeling subsystem
340     current_weather.Init();
341
342     // Initialize the Cockpit subsystem
343     if( fgCockpitInit( &current_aircraft )) {
344         // Cockpit initialized ok.
345     } else {
346         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Cockpit initialization!" );
347         exit(-1);
348     }
349
350     // Initialize the "sky"
351     fgSkyInit();
352
353     // Initialize the flight model subsystem data structures base on
354     // above values
355
356     fgFDMInit( current_options.get_flight_model(), cur_fdm_state, 
357                        1.0 / DEFAULT_MODEL_HZ );
358
359     // I'm just sticking this here for now, it should probably move
360     // eventually
361     scenery.cur_elev = f->get_Runway_altitude() * FEET_TO_METER;
362
363     if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
364         f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
365     }
366
367     FG_LOG( FG_GENERAL, FG_INFO,
368             "Updated position (after elevation adj): ("
369             << (f->get_Latitude() * RAD_TO_DEG) << ", " 
370             << (f->get_Longitude() * RAD_TO_DEG) << ", "
371             << (f->get_Altitude() * FEET_TO_METER) << ")" );
372     // end of thing that I just stuck in that I should probably move
373
374     // Joystick support
375     if ( fgJoystickInit() ) {
376         // Joystick initialized ok.
377     } else {
378         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
379     }
380
381     // Autopilot init added here, by Jeff Goeke-Smith
382     fgAPInit(&current_aircraft);
383
384     // Initialize serial ports
385     fgSerialInit();
386
387     FG_LOG( FG_GENERAL, FG_INFO, endl);
388
389     return(1);
390 }
391
392
393 // $Log$
394 // Revision 1.64  1999/02/01 21:15:43  curt
395 // Removed unused variables.
396 //
397 // Revision 1.63  1999/01/27 04:49:19  curt
398 // Game mode fixes from Norman Vine.
399 // Initial altitude setting tweaks and fixes (especially for when starting
400 // below sea level.)
401 //
402 // Revision 1.62  1999/01/20 13:42:25  curt
403 // Tweaked FDM interface.
404 // Testing check sum support for NMEA serial output.
405 //
406 // Revision 1.61  1999/01/08 03:23:57  curt
407 // Beginning work on compensating for sim time vs. real world time "jitter".
408 //
409 // Revision 1.60  1999/01/07 20:25:09  curt
410 // Updated struct fgGENERAL to class FGGeneral.
411 //
412 // Revision 1.59  1998/12/18 23:40:57  curt
413 // New frame rate counting mechanism.
414 //
415 // Revision 1.58  1998/12/09 18:50:25  curt
416 // Converted "class fgVIEW" to "class FGView" and updated to make data
417 // members private and make required accessor functions.
418 //
419 // Revision 1.57  1998/12/06 14:52:56  curt
420 // Fixed a problem with the initial starting altitude.  "v->abs_view_pos" wasn't
421 // being calculated correctly at the beginning causing the first terrain
422 // intersection to fail, returning a ground altitude of zero, causing the plane
423 // to free fall for one frame, until the ground altitude was corrected, but now
424 // being under the ground we got a big bounce and the plane always ended up
425 // upside down.
426 //
427 // Revision 1.56  1998/12/06 13:51:23  curt
428 // Turned "struct fgWEATHER" into "class FGWeather".
429 //
430 // Revision 1.55  1998/12/05 15:54:20  curt
431 // Renamed class fgFLIGHT to class FGState as per request by JSB.
432 //
433 // Revision 1.54  1998/12/05 14:19:53  curt
434 // Looking into a problem with cur_view_params.abs_view_pos initialization.
435 //
436 // Revision 1.53  1998/12/03 04:25:05  curt
437 // Working on fixing up new fgFLIGHT class.
438 //
439 // Revision 1.52  1998/12/03 01:17:17  curt
440 // Converted fgFLIGHT to a class.
441 //
442 // Revision 1.51  1998/11/20 01:02:37  curt
443 // Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
444 //
445 // Revision 1.50  1998/11/16 14:00:01  curt
446 // Added pow() macro bug work around.
447 // Added support for starting FGFS at various resolutions.
448 // Added some initial serial port support.
449 // Specify default log levels in main().
450 //
451 // Revision 1.49  1998/11/11 00:24:02  curt
452 // Added Michael Johnson's audio patches for testing.
453 // Also did a few tweaks to avoid numerical problems when starting at a place
454 // with no (or bogus) scenery.
455 //
456 // Revision 1.48  1998/11/07 19:07:10  curt
457 // Enable release builds using the --without-logging option to the configure
458 // script.  Also a couple log message cleanups, plus some C to C++ comment
459 // conversion.
460 //
461 // Revision 1.47  1998/11/06 21:18:10  curt
462 // Converted to new logstream debugging facility.  This allows release
463 // builds with no messages at all (and no performance impact) by using
464 // the -DFG_NDEBUG flag.
465 //
466 // Revision 1.46  1998/10/27 02:14:38  curt
467 // Changes to support GLUT joystick routines as fall back.
468 //
469 // Revision 1.45  1998/10/25 10:57:21  curt
470 // Changes to use the new joystick library if it is available.
471 //
472 // Revision 1.44  1998/10/18 01:17:17  curt
473 // Point3D tweaks.
474 //
475 // Revision 1.43  1998/10/17 01:34:22  curt
476 // C++ ifying ...
477 //
478 // Revision 1.42  1998/10/16 23:27:54  curt
479 // C++-ifying.
480 //
481 // Revision 1.41  1998/10/16 00:54:01  curt
482 // Converted to Point3D class.
483 //
484 // Revision 1.40  1998/10/02 12:46:49  curt
485 // Added an "auto throttle"
486 //
487 // Revision 1.39  1998/09/29 02:03:39  curt
488 // Autopilot mods.
489 //
490 // Revision 1.38  1998/09/15 04:27:30  curt
491 // Changes for new Astro code.
492 //
493 // Revision 1.37  1998/09/15 02:09:26  curt
494 // Include/fg_callback.hxx
495 //   Moved code inline to stop g++ 2.7 from complaining.
496 //
497 // Simulator/Time/event.[ch]xx
498 //   Changed return type of fgEVENT::printStat().  void caused g++ 2.7 to
499 //   complain bitterly.
500 //
501 // Minor bugfix and changes.
502 //
503 // Simulator/Main/GLUTmain.cxx
504 //   Added missing type to idle_state definition - eliminates a warning.
505 //
506 // Simulator/Main/fg_init.cxx
507 //   Changes to airport lookup.
508 //
509 // Simulator/Main/options.cxx
510 //   Uses fg_gzifstream when loading config file.
511 //
512 // Revision 1.36  1998/09/08 21:40:08  curt
513 // Fixes by Charlie Hotchkiss.
514 //
515 // Revision 1.35  1998/08/29 13:09:26  curt
516 // Changes to event manager from Bernie Bright.
517 //
518 // Revision 1.34  1998/08/27 17:02:06  curt
519 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
520 // - use strings for fg_root and airport_id and added methods to return
521 //   them as strings,
522 // - inlined all access methods,
523 // - made the parsing functions private methods,
524 // - deleted some unused functions.
525 // - propogated some of these changes out a bit further.
526 //
527 // Revision 1.33  1998/08/25 20:53:32  curt
528 // Shuffled $FG_ROOT file layout.
529 //
530 // Revision 1.32  1998/08/25 16:59:09  curt
531 // Directory reshuffling.
532 //
533 // Revision 1.31  1998/08/22  14:49:57  curt
534 // Attempting to iron out seg faults and crashes.
535 // Did some shuffling to fix a initialization order problem between view
536 // position, scenery elevation.
537 //
538 // Revision 1.30  1998/08/20 20:32:33  curt
539 // Reshuffled some of the code in and around views.[ch]xx
540 //
541 // Revision 1.29  1998/07/30 23:48:27  curt
542 // Output position & orientation when pausing.
543 // Eliminated libtool use.
544 // Added options to specify initial position and orientation.
545 // Changed default fov to 55 degrees.
546 // Added command line option to start in paused or unpaused state.
547 //
548 // Revision 1.28  1998/07/27 18:41:25  curt
549 // Added a pause command "p"
550 // Fixed some initialization order problems between pui and glut.
551 // Added an --enable/disable-sound option.
552 //
553 // Revision 1.27  1998/07/24 21:39:10  curt
554 // Debugging output tweaks.
555 // Cast glGetString to (char *) to avoid compiler errors.
556 // Optimizations to fgGluLookAt() by Norman Vine.
557 //
558 // Revision 1.26  1998/07/22 21:40:44  curt
559 // Clear to adjusted fog color (for sunrise/sunset effects)
560 // Make call to fog sunrise/sunset adjustment method.
561 // Add a stdc++ library bug work around to fg_init.cxx
562 //
563 // Revision 1.25  1998/07/13 21:01:38  curt
564 // Wrote access functions for current fgOPTIONS.
565 //
566 // Revision 1.24  1998/07/13 15:32:39  curt
567 // Clear color buffer if drawing wireframe.
568 // When specifying and airport, start elevation at -1000 and let the system
569 // position you at ground level.
570 //
571 // Revision 1.23  1998/07/12 03:14:43  curt
572 // Added ground collision detection.
573 // Did some serious horsing around to be able to "hug" the ground properly
574 //   and still be able to take off.
575 // Set the near clip plane to 1.0 meters when less than 10 meters above the
576 //   ground.
577 // Did some serious horsing around getting the initial airplane position to be
578 //   correct based on rendered terrain elevation.
579 // Added a little cheat/hack that will prevent the view position from ever
580 //   dropping below the terrain, even when the flight model doesn't quite
581 //   put you as high as you'd like.
582 //
583 // Revision 1.22  1998/07/04 00:52:25  curt
584 // Add my own version of gluLookAt() (which is nearly identical to the
585 // Mesa/glu version.)  But, by calculating the Model View matrix our selves
586 // we can save this matrix without having to read it back in from the video
587 // card.  This hopefully allows us to save a few cpu cycles when rendering
588 // out the fragments because we can just use glLoadMatrixd() with the
589 // precalculated matrix for each tile rather than doing a push(), translate(),
590 // pop() for every fragment.
591 //
592 // Panel status defaults to off for now until it gets a bit more developed.
593 //
594 // Extract OpenGL driver info on initialization.
595 //
596 // Revision 1.21  1998/06/27 16:54:33  curt
597 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
598 // Don't change the view port when displaying the panel.
599 //
600 // Revision 1.20  1998/06/17 21:35:12  curt
601 // Refined conditional audio support compilation.
602 // Moved texture parameter setup calls to ../Scenery/materials.cxx
603 // #include <string.h> before various STL includes.
604 // Make HUD default state be enabled.
605 //
606 // Revision 1.19  1998/06/08 17:57:05  curt
607 // Minor sound/startup position tweaks.
608 //
609 // Revision 1.18  1998/06/03 00:47:14  curt
610 // Updated to compile in audio support if OSS available.
611 // Updated for new version of Steve's audio library.
612 // STL includes don't use .h
613 // Small view optimizations.
614 //
615 // Revision 1.17  1998/06/01 17:54:42  curt
616 // Added Linux audio support.
617 // avoid glClear( COLOR_BUFFER_BIT ) when not using it to set the sky color.
618 // map stl tweaks.
619 //
620 // Revision 1.16  1998/05/29 20:37:24  curt
621 // Tweaked material properties & lighting a bit in GLUTmain.cxx.
622 // Read airport list into a "map" STL for dynamic list sizing and fast tree
623 // based lookups.
624 //
625 // Revision 1.15  1998/05/22 21:28:53  curt
626 // Modifications to use the new fgEVENT_MGR class.
627 //
628 // Revision 1.14  1998/05/20 20:51:35  curt
629 // Tweaked smooth shaded texture lighting properties.
630 // Converted fgLIGHT to a C++ class.
631 //
632 // Revision 1.13  1998/05/16 13:08:35  curt
633 // C++ - ified views.[ch]xx
634 // Shuffled some additional view parameters into the fgVIEW class.
635 // Changed tile-radius to tile-diameter because it is a much better
636 //   name.
637 // Added a WORLD_TO_EYE transformation to views.cxx.  This allows us
638 //  to transform world space to eye space for view frustum culling.
639 //
640 // Revision 1.12  1998/05/13 18:29:58  curt
641 // Added a keyboard binding to dynamically adjust field of view.
642 // Added a command line option to specify fov.
643 // Adjusted terrain color.
644 // Root path info moved to fgOPTIONS.
645 // Added ability to parse options out of a config file.
646 //
647 // Revision 1.11  1998/05/07 23:14:15  curt
648 // Added "D" key binding to set autopilot heading.
649 // Made frame rate calculation average out over last 10 frames.
650 // Borland C++ floating point exception workaround.
651 // Added a --tile-radius=n option.
652 //
653 // Revision 1.10  1998/05/06 03:16:24  curt
654 // Added an averaged global frame rate counter.
655 // Added an option to control tile radius.
656 //
657 // Revision 1.9  1998/05/03 00:47:31  curt
658 // Added an option to enable/disable full-screen mode.
659 //
660 // Revision 1.8  1998/04/30 12:34:18  curt
661 // Added command line rendering options:
662 //   enable/disable fog/haze
663 //   specify smooth/flat shading
664 //   disable sky blending and just use a solid color
665 //   enable wireframe drawing mode
666 //
667 // Revision 1.7  1998/04/28 01:20:22  curt
668 // Type-ified fgTIME and fgVIEW.
669 // Added a command line option to disable textures.
670 //
671 // Revision 1.6  1998/04/26 05:10:03  curt
672 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
673 //
674 // Revision 1.5  1998/04/25 22:06:30  curt
675 // Edited cvs log messages in source files ... bad bad bad!
676 //
677 // Revision 1.4  1998/04/25 20:24:01  curt
678 // Cleaned up initialization sequence to eliminate interdependencies
679 // between sun position, lighting, and view position.  This creates a
680 // valid single pass initialization path.
681 //
682 // Revision 1.3  1998/04/25 15:11:11  curt
683 // Added an command line option to set starting position based on airport ID.
684 //
685 // Revision 1.2  1998/04/24 00:49:20  curt
686 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
687 // Trying out some different option parsing code.
688 // Some code reorganization.
689 //
690 // Revision 1.1  1998/04/22 13:25:44  curt
691 // C++ - ifing the code.
692 // Starting a bit of reorganization of lighting code.
693 //
694 // Revision 1.56  1998/04/18 04:11:28  curt
695 // Moved fg_debug to it's own library, added zlib support.
696 //
697 // Revision 1.55  1998/04/14 02:21:03  curt
698 // Incorporated autopilot heading hold contributed by:  Jeff Goeke-Smith
699 // <jgoeke@voyager.net>
700 //
701 // Revision 1.54  1998/04/08 23:35:36  curt
702 // Tweaks to Gnu automake/autoconf system.
703 //
704 // Revision 1.53  1998/04/03 22:09:06  curt
705 // Converting to Gnu autoconf system.
706 //
707 // Revision 1.52  1998/03/23 21:24:38  curt
708 // Source code formating tweaks.
709 //
710 // Revision 1.51  1998/03/14 00:31:22  curt
711 // Beginning initial terrain texturing experiments.
712 //
713 // Revision 1.50  1998/03/09 22:46:19  curt
714 // Minor tweaks.
715 //
716 // Revision 1.49  1998/02/23 19:07:59  curt
717 // Incorporated Durk's Astro/ tweaks.  Includes unifying the sun position
718 // calculation code between sun display, and other FG sections that use this
719 // for things like lighting.
720 //
721 // Revision 1.48  1998/02/21 14:53:15  curt
722 // Added Charlie's HUD changes.
723 //
724 // Revision 1.47  1998/02/19 13:05:53  curt
725 // Incorporated some HUD tweaks from Michelle America.
726 // Tweaked the sky's sunset/rise colors.
727 // Other misc. tweaks.
728 //
729 // Revision 1.46  1998/02/18 15:07:06  curt
730 // Tweaks to build with SGI OpenGL (and therefor hopefully other accelerated
731 // drivers will work.)
732 //
733 // Revision 1.45  1998/02/16 13:39:43  curt
734 // Miscellaneous weekend tweaks.  Fixed? a cache problem that caused whole
735 // tiles to occasionally be missing.
736 //
737 // Revision 1.44  1998/02/12 21:59:50  curt
738 // Incorporated code changes contributed by Charlie Hotchkiss
739 // <chotchkiss@namg.us.anritsu.com>
740 //
741 // Revision 1.43  1998/02/11 02:50:40  curt
742 // Minor changes.
743 //
744 // Revision 1.42  1998/02/09 22:56:58  curt
745 // Removed "depend" files from cvs control.  Other minor make tweaks.
746 //
747 // Revision 1.41  1998/02/09 15:07:50  curt
748 // Minor tweaks.
749 //
750 // Revision 1.40  1998/02/07 15:29:44  curt
751 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
752 // <chotchkiss@namg.us.anritsu.com>
753 //
754 // Revision 1.39  1998/02/03 23:20:25  curt
755 // Lots of little tweaks to fix various consistency problems discovered by
756 // Solaris' CC.  Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
757 // passed arguments along to the real printf().  Also incorporated HUD changes
758 // by Michele America.
759 //
760 // Revision 1.38  1998/02/02 20:53:58  curt
761 // Incorporated Durk's changes.
762 //
763 // Revision 1.37  1998/02/01 03:39:54  curt
764 // Minor tweaks.
765 //
766 // Revision 1.36  1998/01/31 00:43:13  curt
767 // Added MetroWorks patches from Carmen Volpe.
768 //
769 // Revision 1.35  1998/01/27 00:47:57  curt
770 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
771 // system and commandline/config file processing code.
772 //
773 // Revision 1.34  1998/01/22 02:59:37  curt
774 // Changed #ifdef FILE_H to #ifdef _FILE_H
775 //
776 // Revision 1.33  1998/01/21 21:11:34  curt
777 // Misc. tweaks.
778 //
779 // Revision 1.32  1998/01/19 19:27:08  curt
780 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
781 // This should simplify things tremendously.
782 //
783 // Revision 1.31  1998/01/19 18:40:32  curt
784 // Tons of little changes to clean up the code and to remove fatal errors
785 // when building with the c++ compiler.
786 //
787 // Revision 1.30  1998/01/13 00:23:09  curt
788 // Initial changes to support loading and management of scenery tiles.  Note,
789 // there's still a fair amount of work left to be done.
790 //
791 // Revision 1.29  1998/01/08 02:22:08  curt
792 // Beginning to integrate Tile management subsystem.
793 //
794 // Revision 1.28  1998/01/07 03:18:58  curt
795 // Moved astronomical stuff from .../Src/Scenery to .../Src/Astro/
796 //
797 // Revision 1.27  1998/01/05 18:44:35  curt
798 // Add an option to advance/decrease time from keyboard.
799 //
800 // Revision 1.26  1997/12/30 23:09:04  curt
801 // Tweaking initialization sequences.
802 //
803 // Revision 1.25  1997/12/30 22:22:33  curt
804 // Further integration of event manager.
805 //
806 // Revision 1.24  1997/12/30 20:47:44  curt
807 // Integrated new event manager with subsystem initializations.
808 //
809 // Revision 1.23  1997/12/30 16:36:50  curt
810 // Merged in Durk's changes ...
811 //
812 // Revision 1.22  1997/12/19 23:34:05  curt
813 // Lot's of tweaking with sky rendering and lighting.
814 //
815 // Revision 1.21  1997/12/19 16:45:00  curt
816 // Working on scene rendering order and options.
817 //
818 // Revision 1.20  1997/12/18 23:32:33  curt
819 // First stab at sky dome actually starting to look reasonable. :-)
820 //
821 // Revision 1.19  1997/12/17 23:13:36  curt
822 // Began working on rendering a sky.
823 //
824 // Revision 1.18  1997/12/15 23:54:49  curt
825 // Add xgl wrappers for debugging.
826 // Generate terrain normals on the fly.
827 //
828 // Revision 1.17  1997/12/15 20:59:09  curt
829 // Misc. tweaks.
830 //
831 // Revision 1.16  1997/12/12 19:52:48  curt
832 // Working on lightling and material properties.
833 //
834 // Revision 1.15  1997/12/11 04:43:55  curt
835 // Fixed sun vector and lighting problems.  I thing the moon is now lit
836 // correctly.
837 //
838 // Revision 1.14  1997/12/10 22:37:47  curt
839 // Prepended "fg" on the name of all global structures that didn't have it yet.
840 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
841 //
842 // Revision 1.13  1997/11/25 19:25:32  curt
843 // Changes to integrate Durk's moon/sun code updates + clean up.
844 //
845 // Revision 1.12  1997/11/15 18:16:35  curt
846 // minor tweaks.
847 //
848 // Revision 1.11  1997/10/30 12:38:42  curt
849 // Working on new scenery subsystem.
850 //
851 // Revision 1.10  1997/10/25 03:24:23  curt
852 // Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
853 //
854 // Revision 1.9  1997/09/23 00:29:39  curt
855 // Tweaks to get things to compile with gcc-win32.
856 //
857 // Revision 1.8  1997/09/22 14:44:20  curt
858 // Continuing to try to align stars correctly.
859 //
860 // Revision 1.7  1997/09/16 15:50:30  curt
861 // Working on star alignment and time issues.
862 //
863 // Revision 1.6  1997/09/05 14:17:30  curt
864 // More tweaking with stars.
865 //
866 // Revision 1.5  1997/09/04 02:17:36  curt
867 // Shufflin' stuff.
868 //
869 // Revision 1.4  1997/08/27 21:32:26  curt
870 // Restructured view calculation code.  Added stars.
871 //
872 // Revision 1.3  1997/08/27 03:30:19  curt
873 // Changed naming scheme of basic shared structures.
874 //
875 // Revision 1.2  1997/08/25 20:27:23  curt
876 // Merged in initial HUD and Joystick code.
877 //
878 // Revision 1.1  1997/08/23 01:46:20  curt
879 // Initial revision.
880 //
881