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