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