1 /**************************************************************************
2 * GLUTmain.c -- top level sim routines
4 * Written by Curtis Olson for OpenGL, started May 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.
23 * (Log is kept at end of this file)
24 **************************************************************************/
36 #include <Main/GLUTkey.h>
37 #include <Main/fg_init.h>
38 #include <Main/fg_debug.h>
39 #include <Main/fg_getopt.h>
40 #include <Main/views.h>
42 #include <Include/cmdargs.h> // Line to command line arguments
43 #include <Include/fg_constants.h>
44 #include <Include/general.h>
46 #include <Aircraft/aircraft.h>
47 #include <Astro/moon.h>
48 #include <Astro/planets.h>
49 #include <Astro/sky.h>
50 #include <Astro/stars.h>
51 #include <Astro/sun.h>
52 #include <Cockpit/cockpit.h>
53 #include <Joystick/joystick.h>
54 #include <Math/fg_geodesy.h>
55 #include <Math/mat3.h>
56 #include <Math/polar.h>
57 #include <Scenery/scenery.h>
58 #include <Scenery/tilemgr.h>
59 #include <Time/event.h>
60 #include <Time/fg_time.h>
61 #include <Time/fg_timer.h>
62 #include <Time/sunpos.h>
63 #include <Weather/weather.h>
66 /* This is a record containing global housekeeping information */
67 struct fgGENERAL general;
70 static GLfloat win_ratio = 1.0;
71 static GLint winWidth, winHeight;
74 /* pointer to scenery structure */
75 /* static GLint scenery, runway; */
82 /* Yet another hack. This one used by the HUD code. Michele */
85 /* Yet another other hack. Used for my prototype instrument code. (Durk) */
86 int displayInstruments;
88 // The following defines flight gear options. Because glutlib will also
89 // want to parse its own options, those options must not be included here
90 // or they will get parsed by the main program option parser. Hence case
91 // is significant for any option added that might be in conflict with
94 // glutlib parses for:
96 // -direct (invalid in Win32)
100 // -indirect (invalid in Win32)
103 // Note that glutlib depends upon strings while this program's
104 // option parser wants only initial characters followed by numbers
107 const char *fg_cmdargopts = "a:c:Hhp:r:v:x:?";
110 // -a aircraftfilename aircraft start over ride
111 // -c0x0000 - 0xffffffff debug class setting
112 // H,h.? help on command line use (does not need Option struct)
114 // -r flightgear root path to program support files
115 // -v0 -v1 initial view mode (hud/no_hud currently)
116 // -xlogpathname debug logfile name
118 // Defaults in arguments to indicate not set on command line.
119 // Program defaults set variables from constants if neither command
120 // options or environmental variables effect values.
123 char acArgbuf [ MAXPATH + 1] = "\0";
124 int debugArgValue = -2;
125 int priorityArgValue = -1;
126 char rootArgbuf [ MAXPATH + 1] = "\0";
128 char logArgbuf [ MAXPATH + 1] = "\0";
130 // There is a reason for defining the option structs by name and then
131 // creating an array of pointers to options. C++ is unfriendly to
132 // initializing arrays of objects that are not built in types. Always
133 // look forward. (Besides, you can follow what is going on better and
134 // add or modify with greater security. -ch
136 Option aircraftOption = { 'a',
139 "Startup aircraft pathname override"
141 Option debugOption = { 'c',
142 OPT_LHEX, // Long int (32 bits)
146 Option priorityOption = { 'p',
149 "Debug priority Threshold"
151 Option rootOption = { 'r',
154 "Root directory for execution"
156 Option hudOption = { 'v',
159 "View mode start" // HUD,Panel,Chase,Tower
161 Option logfileOption = { 'x',
164 "Debug log file name"
168 #define OptsDefined 6
169 Option *CmdLineOptions[ OptsDefined ] = {
178 const char *DefaultRootDir = "\\Flightgear";
179 const char *DefaultAircraft = "Navion.acf";
180 const char *DefaultDebuglog = "fgdebug.log";
181 const int DefaultViewMode = HUD_VIEW;
183 // Debug defaults handled in fg_debug.c
185 /**************************************************************************
186 * fgInitVisuals() -- Initialize various GL/view parameters
187 **************************************************************************/
189 static void fgInitVisuals( void ) {
193 l = &cur_light_params;
194 w = ¤t_weather;
196 /* xglDisable( GL_DITHER ); */
198 /* If enabled, normal vectors specified with glNormal are scaled
199 to unit length after transformation. See glNormal. */
200 xglEnable( GL_NORMALIZE );
202 xglEnable( GL_LIGHTING );
203 xglEnable( GL_LIGHT0 );
204 xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
206 xglFogi (GL_FOG_MODE, GL_LINEAR);
207 /* xglFogf (GL_FOG_START, 1.0); */
208 xglFogf (GL_FOG_END, w->visibility);
209 /* xglFogf (GL_FOG_DENSITY, w->visibility); */
210 xglHint (GL_FOG_HINT, GL_NICEST /* GL_FASTEST */ );
212 /* draw wire frame */
213 /* xglPolygonMode(GL_FRONT_AND_BACK,GL_LINE); */
217 /**************************************************************************
218 * Update the view volume, position, and orientation
219 **************************************************************************/
221 static void fgUpdateViewParams( void ) {
227 f = current_aircraft.flight;
228 l = &cur_light_params;
229 // t = &cur_time_params;
232 fgViewUpdate(f, v, l);
234 if (displayInstruments)
236 xglViewport(0, (GLint)(winHeight / 2 ) , (GLint)winWidth, (GLint)winHeight / 2);
237 /* Tell GL we are about to modify the projection parameters */
238 xglMatrixMode(GL_PROJECTION);
240 gluPerspective(55.0, 2.0/win_ratio, 1.0, 100000.0);
244 xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
245 /* Tell GL we are about to modify the projection parameters */
246 xglMatrixMode(GL_PROJECTION);
248 gluPerspective(55.0, 1.0/win_ratio, 1.0, 100000.0);
251 xglMatrixMode(GL_MODELVIEW);
254 /* set up our view volume (default) */
255 gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
256 v->view_pos.x + v->view_forward[0],
257 v->view_pos.y + v->view_forward[1],
258 v->view_pos.z + v->view_forward[2],
259 v->view_up[0], v->view_up[1], v->view_up[2]);
261 /* lock view horizontally towards sun (testing) */
262 /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
263 v->view_pos.x + v->surface_to_sun[0],
264 v->view_pos.y + v->surface_to_sun[1],
265 v->view_pos.z + v->surface_to_sun[2],
266 v->view_up[0], v->view_up[1], v->view_up[2]); */
268 /* lock view horizontally towards south (testing) */
269 /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
270 v->view_pos.x + v->surface_south[0],
271 v->view_pos.y + v->surface_south[1],
272 v->view_pos.z + v->surface_south[2],
273 v->view_up[0], v->view_up[1], v->view_up[2]); */
275 /* set the sun position */
276 xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
280 /*************************************************************************
281 * Draw a basic instrument panel
282 ************************************************************************/
283 static void fgUpdateInstrViewParams( void ) {
284 xglViewport(0, 0 , (GLint)winWidth, (GLint)winHeight / 2);
286 xglMatrixMode(GL_PROJECTION);
290 gluOrtho2D(0, 640, 0, 480);
291 xglMatrixMode(GL_MODELVIEW);
295 xglColor3f(1.0, 1.0, 1.0);
298 xglDisable(GL_DEPTH_TEST);
299 xglDisable(GL_LIGHTING);
302 xglColor3f (0.5, 0.5, 0.5);
305 xglVertex2f(0.0, 0.00);
306 xglVertex2f(0.0, 480.0);
307 xglVertex2f(640.0,480.0);
308 xglVertex2f(640.0, 0.0);
311 xglRectf(0.0,0.0, 640, 480);
312 xglEnable(GL_DEPTH_TEST);
313 xglEnable(GL_LIGHTING);
314 xglMatrixMode(GL_PROJECTION);
316 xglMatrixMode(GL_MODELVIEW);
321 /**************************************************************************
322 * Update all Visuals (redraws anything graphics related)
323 **************************************************************************/
325 static void fgRenderFrame( void ) {
330 GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
332 l = &cur_light_params;
333 t = &cur_time_params;
336 /* update view volume parameters */
337 fgUpdateViewParams();
339 xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
341 /* Tell GL we are switching to model view parameters */
342 xglMatrixMode(GL_MODELVIEW);
343 /* xglLoadIdentity(); */
346 xglDisable( GL_DEPTH_TEST );
347 xglDisable( GL_LIGHTING );
348 xglDisable( GL_CULL_FACE );
349 xglDisable( GL_FOG );
350 xglShadeModel( GL_SMOOTH );
353 /* setup transformation for drawing astronomical objects */
355 /* Translate to view position */
356 xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
357 /* Rotate based on gst (sidereal time) */
358 angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
359 /* printf("Rotating astro objects by %.2f degrees\n",angle); */
360 xglRotatef( angle, 0.0, 0.0, -1.0 );
362 /* draw stars and planets */
369 /* render the moon */
370 xglEnable( GL_LIGHTING );
371 /* set lighting parameters */
372 xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
373 xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
374 xglEnable( GL_CULL_FACE );
376 /* Let's try some blending technique's (Durk)*/
378 glBlendFunc(GL_ONE, GL_ONE);
385 xglShadeModel( /* GL_FLAT */ GL_SMOOTH );
386 xglEnable( GL_DEPTH_TEST );
388 xglFogfv (GL_FOG_COLOR, l->fog_color);
389 /* set lighting parameters */
390 xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
391 xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
393 /* fgSceneryRender(); */
400 /* display instruments */
401 if (displayInstruments) {
402 fgUpdateInstrViewParams();
409 /**************************************************************************
410 * Update internal time dependent calculations (i.e. flight model)
411 **************************************************************************/
413 void fgUpdateTimeDepCalcs(int multi_loop) {
419 f = current_aircraft.flight;
420 t = &cur_time_params;
423 /* update the flight model */
424 if ( multi_loop < 0 ) {
425 multi_loop = DEFAULT_MULTILOOP;
428 /* printf("updating flight model x %d\n", multi_loop); */
429 fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
431 /* update the view angle */
432 for ( i = 0; i < multi_loop; i++ ) {
433 if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
434 v->view_offset = v->goal_view_offset;
437 /* move v->view_offset towards v->goal_view_offset */
438 if ( v->goal_view_offset > v->view_offset ) {
439 if ( v->goal_view_offset - v->view_offset < FG_PI ) {
440 v->view_offset += 0.01;
442 v->view_offset -= 0.01;
445 if ( v->view_offset - v->goal_view_offset < FG_PI ) {
446 v->view_offset -= 0.01;
448 v->view_offset += 0.01;
451 if ( v->view_offset > FG_2PI ) {
452 v->view_offset -= FG_2PI;
453 } else if ( v->view_offset < 0 ) {
454 v->view_offset += FG_2PI;
461 void fgInitTimeDepCalcs( void ) {
462 /* initialize timer */
465 fgTimerInit( 1.0 / DEFAULT_TIMER_HZ, fgUpdateTimeDepCalcs );
471 /**************************************************************************
472 * Scenery management routines
473 **************************************************************************/
475 /* static void fgSceneryInit_OLD() { */
477 /* scenery = fgSceneryCompile_OLD();
478 runway = fgRunwayHack_OLD(0.69, 53.07);
482 /* create the scenery */
483 /* GLint fgSceneryCompile_OLD() {
486 scenery = mesh2GL(mesh_ptr_OLD);
492 /* hack in a runway */
493 /* GLint fgRunwayHack_OLD(double width, double length) {
494 static GLfloat concrete[4] = { 0.5, 0.5, 0.5, 1.0 };
495 static GLfloat line[4] = { 0.9, 0.9, 0.9, 1.0 };
498 float line_len, line_width_2, cur_pos;
500 runway = xglGenLists(1);
501 xglNewList(runway, GL_COMPILE);
504 /* xglBegin(GL_POLYGON);
505 xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete );
506 xglNormal3f(0.0, 0.0, 1.0);
508 xglVertex3d( 0.0, -width/2.0, 0.0);
509 xglVertex3d( 0.0, width/2.0, 0.0);
510 xglVertex3d(length, width/2.0, 0.0);
511 xglVertex3d(length, -width/2.0, 0.0);
514 /* draw center line */
515 /* xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line );
516 line_len = length / ( 2 * num_lines + 1);
517 printf("line_len = %.3f\n", line_len);
520 for ( i = 0; i < num_lines; i++ ) {
521 xglBegin(GL_POLYGON);
522 xglVertex3d( cur_pos, -line_width_2, 0.005);
523 xglVertex3d( cur_pos, line_width_2, 0.005);
525 xglVertex3d( cur_pos, line_width_2, 0.005);
526 xglVertex3d( cur_pos, -line_width_2, 0.005);
537 /* draw the scenery */
538 /*static void fgSceneryDraw_OLD() {
539 static float z = 32.35;
543 xglCallList(scenery);
545 printf("*** Drawing runway at %.2f\n", z);
547 xglTranslatef( -398391.28, 120070.41, 32.35);
548 xglRotatef(170.0, 0.0, 0.0, 1.0);
556 /* What should we do when we have nothing else to do? How about get
557 * ready for the next move and update the display? */
558 static void fgMainLoop( void ) {
559 static int remainder = 0;
560 int elapsed, multi_loop;
562 /* double joy_x, joy_y; */
563 /* int joy_b1, joy_b2; */
568 fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
569 fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
571 a = ¤t_aircraft;
573 t = &cur_time_params;
579 /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
580 printf( "Joystick X %f Y %f B1 %d B2 %d\n",
581 joy_x, joy_y, joy_b1, joy_b2 );
583 fgAileronSet( joy_x ); */
585 /* Calculate model iterations needed */
586 elapsed = fgGetTimeInterval();
587 fgPrintf( FG_ALL, FG_BULK,
588 "Time interval is = %d, previous remainder is = %d\n",
590 fgPrintf( FG_ALL, FG_BULK,
591 "--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed);
592 elapsed += remainder;
594 multi_loop = (int)(((float)elapsed * 0.001) * DEFAULT_MODEL_HZ);
595 remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
596 fgPrintf( FG_ALL, FG_BULK,
597 "Model iterations needed = %d, new remainder = %d\n",
598 multi_loop, remainder);
600 /* Run flight model */
601 if ( ! use_signals ) {
603 fgUpdateTimeDepCalcs(multi_loop);
606 /* I'm just sticking this here for now, it should probably move
608 /* cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
609 FG_Latitude * RAD_TO_ARCSEC); */
610 /* there is no ground collision detection really, so for now I
611 * just hard code the ground elevation to be 0 */
614 /* printf("Ground elevation is %.2f meters here.\n", cur_elev); */
615 /* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
617 if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
618 /* set this here, otherwise if we set runway height above our
619 current height we get a really nasty bounce. */
620 FG_Runway_altitude = FG_Altitude - 3.758099;
622 /* now set aircraft altitude above ground */
623 FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
624 fgPrintf( FG_ALL, FG_BULK, "<*> resetting altitude to %.0f meters\n",
625 FG_Altitude * FEET_TO_METER);
628 fgAircraftOutputCurrent(a);
630 /* see if we need to load any new scenery tiles */
633 /* Process/manage pending events */
639 fgPrintf( FG_ALL, FG_DEBUG, "\n");
643 /**************************************************************************
644 * Handle new window size or exposure
645 **************************************************************************/
647 static void fgReshape( int width, int height ) {
648 /* Do this so we can call fgReshape(0,0) ourselves without having to know
649 * what the values of width & height are. */
650 if ( (height > 0) && (width > 0) ) {
651 win_ratio = (GLfloat) height / (GLfloat) width;
657 /* Inform gl of our view window size (now handled elsewhere) */
658 /* xglViewport(0, 0, (GLint)width, (GLint)height); */
660 fgUpdateViewParams();
662 /* xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); */
666 /**************************************************************************
668 **************************************************************************/
670 int main( int argc, char *argv[] ) {
672 int parse_result; // Used in command line argument.
674 f = current_aircraft.flight;
675 // First things first... We must have startup options dealt with.
678 #define VERSION "src-32A"
680 printf("Flight Gear: Version %s\n\n", VERSION);
682 /*********************************************************************
683 * Initialize the Window/Graphics environment.
684 **********************************************************************/
686 /* initialize GLUT */
687 xglutInit(&argc, argv);
689 /* Define Display Parameters */
690 xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
692 /* Define initial window size */
693 xglutInitWindowSize(640, 480);
695 /* Initialize windows */
696 xglutCreateWindow("Flight Gear");
698 // xglutInit above will extract all non-general program command line.
699 // We only need wory about our own.
701 parse_result = getargs( argc, argv, OptsDefined, CmdLineOptions, NULL);
703 switch( parse_result ) {
708 print_desc( OptsDefined, CmdLineOptions );
713 printf( "Flight Gear: Command line invalid.");
717 // Deal with the effects of options no set by manipulating the command
718 // line, or possibly set to invalid states.
720 if(( viewArg >= 0) && (viewArg < 1)) {
721 show_hud = viewArg; // For now view_mode TRUE - no HUD, else show_hud.
723 show_hud = DefaultViewMode;
726 // All other command line option responses are handled in the various
727 // initialization routines (or ignored if not implemented.
729 // This is the general house keeping init routine. It initializes the
730 // debug trail scheme and then any other stuff.
732 if( !fgInitGeneral()) {
734 // This is the top level init routine which calls all the other
735 // subsystem initialization routines. If you are adding a
736 // subsystem to flight gear, its initialization call should
737 // located in this routine.
738 if( !fgInitSubsystems()) {
740 // setup view parameters, only makes GL calls
744 /* init timer routines, signals, etc. Arrange for an alarm
745 signal to be generated, etc. */
746 fgInitTimeDepCalcs();
749 /**********************************************************
750 * Initialize the GLUT Event Handlers.
751 **********************************************************/
753 // call fgReshape() on window resizes
754 xglutReshapeFunc( fgReshape );
756 // call key() on keyboard event
757 xglutKeyboardFunc( GLUTkey );
758 glutSpecialFunc( GLUTspecialkey );
760 // call fgMainLoop() whenever there is
761 // nothing else to do
762 xglutIdleFunc( fgMainLoop );
765 xglutDisplayFunc( fgRenderFrame );
767 // pass control off to the GLUT event handler
770 } // End if subsystems initialize ok
771 } // End if general initializations went ok
773 if( fg_DebugOutput ) {
774 fclose( fg_DebugOutput );
782 void __eprintf( void ) {
788 /* Revision 1.61 1998/02/12 21:59:46 curt
789 /* Incorporated code changes contributed by Charlie Hotchkiss
790 /* <chotchkiss@namg.us.anritsu.com>
792 * Revision 1.60 1998/02/11 02:50:40 curt
795 * Revision 1.59 1998/02/09 22:56:54 curt
796 * Removed "depend" files from cvs control. Other minor make tweaks.
798 * Revision 1.58 1998/02/09 15:07:49 curt
801 * Revision 1.57 1998/02/07 15:29:40 curt
802 * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
803 * <chotchkiss@namg.us.anritsu.com>
805 * Revision 1.56 1998/02/03 23:20:23 curt
806 * Lots of little tweaks to fix various consistency problems discovered by
807 * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
808 * passed arguments along to the real printf(). Also incorporated HUD changes
809 * by Michele America.
811 * Revision 1.55 1998/02/02 20:53:58 curt
812 * Incorporated Durk's changes.
814 * Revision 1.54 1998/01/31 00:43:10 curt
815 * Added MetroWorks patches from Carmen Volpe.
817 * Revision 1.53 1998/01/27 18:35:54 curt
820 * Revision 1.52 1998/01/27 00:47:56 curt
821 * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
822 * system and commandline/config file processing code.
824 * Revision 1.51 1998/01/26 15:57:05 curt
825 * Tweaks for dynamic scenery development.
827 * Revision 1.50 1998/01/19 19:27:07 curt
828 * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
829 * This should simplify things tremendously.
831 * Revision 1.49 1998/01/19 18:40:31 curt
832 * Tons of little changes to clean up the code and to remove fatal errors
833 * when building with the c++ compiler.
835 * Revision 1.48 1998/01/19 18:35:46 curt
836 * Minor tweaks and fixes for cygwin32.
838 * Revision 1.47 1998/01/13 00:23:08 curt
839 * Initial changes to support loading and management of scenery tiles. Note,
840 * there's still a fair amount of work left to be done.
842 * Revision 1.46 1998/01/08 02:22:06 curt
843 * Beginning to integrate Tile management subsystem.
845 * Revision 1.45 1998/01/07 03:18:55 curt
846 * Moved astronomical stuff from .../Src/Scenery to .../Src/Astro/
848 * Revision 1.44 1997/12/30 22:22:31 curt
849 * Further integration of event manager.
851 * Revision 1.43 1997/12/30 20:47:43 curt
852 * Integrated new event manager with subsystem initializations.
854 * Revision 1.42 1997/12/30 16:36:47 curt
855 * Merged in Durk's changes ...
857 * Revision 1.41 1997/12/30 13:06:56 curt
858 * A couple lighting tweaks ...
860 * Revision 1.40 1997/12/30 01:38:37 curt
861 * Switched back to per vertex normals and smooth shading for terrain.
863 * Revision 1.39 1997/12/22 23:45:45 curt
864 * First stab at sunset/sunrise sky glow effects.
866 * Revision 1.38 1997/12/22 04:14:28 curt
867 * Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
869 * Revision 1.37 1997/12/19 23:34:03 curt
870 * Lot's of tweaking with sky rendering and lighting.
872 * Revision 1.36 1997/12/19 16:44:57 curt
873 * Working on scene rendering order and options.
875 * Revision 1.35 1997/12/18 23:32:32 curt
876 * First stab at sky dome actually starting to look reasonable. :-)
878 * Revision 1.34 1997/12/17 23:13:34 curt
879 * Began working on rendering a sky.
881 * Revision 1.33 1997/12/15 23:54:45 curt
882 * Add xgl wrappers for debugging.
883 * Generate terrain normals on the fly.
885 * Revision 1.32 1997/12/15 20:59:08 curt
888 * Revision 1.31 1997/12/12 21:41:25 curt
889 * More light/material property tweaking ... still a ways off.
891 * Revision 1.30 1997/12/12 19:52:47 curt
892 * Working on lightling and material properties.
894 * Revision 1.29 1997/12/11 04:43:54 curt
895 * Fixed sun vector and lighting problems. I thing the moon is now lit
898 * Revision 1.28 1997/12/10 22:37:45 curt
899 * Prepended "fg" on the name of all global structures that didn't have it yet.
900 * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
902 * Revision 1.27 1997/12/09 05:11:54 curt
903 * Working on tweaking lighting.
905 * Revision 1.26 1997/12/09 04:25:29 curt
906 * Working on adding a global lighting params structure.
908 * Revision 1.25 1997/12/08 22:54:09 curt
909 * Enabled GL_CULL_FACE.
911 * Revision 1.24 1997/11/25 19:25:32 curt
912 * Changes to integrate Durk's moon/sun code updates + clean up.
914 * Revision 1.23 1997/11/15 18:16:34 curt
917 * Revision 1.22 1997/10/30 12:38:41 curt
918 * Working on new scenery subsystem.
920 * Revision 1.21 1997/09/23 00:29:38 curt
921 * Tweaks to get things to compile with gcc-win32.
923 * Revision 1.20 1997/09/22 14:44:19 curt
924 * Continuing to try to align stars correctly.
926 * Revision 1.19 1997/09/18 16:20:08 curt
927 * At dusk/dawn add/remove stars in stages.
929 * Revision 1.18 1997/09/16 22:14:51 curt
930 * Tweaked time of day lighting equations. Don't draw stars during the day.
932 * Revision 1.17 1997/09/16 15:50:29 curt
933 * Working on star alignment and time issues.
935 * Revision 1.16 1997/09/13 02:00:06 curt
936 * Mostly working on stars and generating sidereal time for accurate star
939 * Revision 1.15 1997/09/05 14:17:27 curt
940 * More tweaking with stars.
942 * Revision 1.14 1997/09/05 01:35:53 curt
943 * Working on getting stars right.
945 * Revision 1.13 1997/09/04 02:17:34 curt
948 * Revision 1.12 1997/08/27 21:32:24 curt
949 * Restructured view calculation code. Added stars.
951 * Revision 1.11 1997/08/27 03:30:16 curt
952 * Changed naming scheme of basic shared structures.
954 * Revision 1.10 1997/08/25 20:27:22 curt
955 * Merged in initial HUD and Joystick code.
957 * Revision 1.9 1997/08/22 21:34:39 curt
958 * Doing a bit of reorganizing and house cleaning.
960 * Revision 1.8 1997/08/19 23:55:03 curt
961 * Worked on better simulating real lighting.
963 * Revision 1.7 1997/08/16 12:22:38 curt
964 * Working on improving the lighting/shading.
966 * Revision 1.6 1997/08/13 20:24:56 curt
967 * Changes due to changing sunpos interface.
969 * Revision 1.5 1997/08/06 21:08:32 curt
970 * Sun position now *really* works (I think) ... I still have sun time warping
971 * code in place, probably should remove it soon.
973 * Revision 1.4 1997/08/06 15:41:26 curt
974 * Working on correct sun position.
976 * Revision 1.3 1997/08/06 00:24:22 curt
977 * Working on correct real time sun lighting.
979 * Revision 1.2 1997/08/04 20:25:15 curt
980 * Organizational tweaking.
982 * Revision 1.1 1997/08/02 18:45:00 curt
983 * Renamed GLmain.c GLUTmain.c
985 * Revision 1.43 1997/08/02 16:23:47 curt
988 * Revision 1.42 1997/08/01 19:43:33 curt
989 * Making progress with coordinate system overhaul.
991 * Revision 1.41 1997/07/31 22:52:37 curt
992 * Working on redoing internal coordinate systems & scenery transformations.
994 * Revision 1.40 1997/07/30 16:12:42 curt
995 * Moved fg_random routines from Util/ to Math/
997 * Revision 1.39 1997/07/21 14:45:01 curt
1000 * Revision 1.38 1997/07/19 23:04:47 curt
1001 * Added an initial weather section.
1003 * Revision 1.37 1997/07/19 22:34:02 curt
1004 * Moved PI definitions to ../constants.h
1005 * Moved random() stuff to ../Utils/ and renamed fg_random()
1007 * Revision 1.36 1997/07/18 23:41:25 curt
1008 * Tweaks for building with Cygnus Win32 compiler.
1010 * Revision 1.35 1997/07/18 14:28:34 curt
1011 * Hacked in some support for wind/turbulence.
1013 * Revision 1.34 1997/07/16 20:04:48 curt
1014 * Minor tweaks to aid Win32 port.
1016 * Revision 1.33 1997/07/12 03:50:20 curt
1017 * Added an #include <Windows32/Base.h> to help compiling for Win32
1019 * Revision 1.32 1997/07/11 03:23:18 curt
1020 * Solved some scenery display/orientation problems. Still have a positioning
1021 * (or transformation?) problem.
1023 * Revision 1.31 1997/07/11 01:29:58 curt
1024 * More tweaking of terrian floor.
1026 * Revision 1.30 1997/07/10 04:26:37 curt
1027 * We now can interpolated ground elevation for any position in the grid. We
1028 * can use this to enforce a "hard" ground. We still need to enforce some
1029 * bounds checking so that we don't try to lookup data points outside the
1032 * Revision 1.29 1997/07/09 21:31:12 curt
1033 * Working on making the ground "hard."
1035 * Revision 1.28 1997/07/08 18:20:12 curt
1036 * Working on establishing a hard ground.
1038 * Revision 1.27 1997/07/07 20:59:49 curt
1039 * Working on scenery transformations to enable us to fly fluidly over the
1040 * poles with no discontinuity/distortion in scenery.
1042 * Revision 1.26 1997/07/05 20:43:34 curt
1043 * renamed mat3 directory to Math so we could add other math related routines.
1045 * Revision 1.25 1997/06/29 21:19:17 curt
1046 * Working on scenery management system.
1048 * Revision 1.24 1997/06/26 22:14:53 curt
1049 * Beginning work on a scenery management system.
1051 * Revision 1.23 1997/06/26 19:08:33 curt
1052 * Restructuring make, adding automatic "make dep" support.
1054 * Revision 1.22 1997/06/25 15:39:47 curt
1055 * Minor changes to compile with rsxnt/win32.
1057 * Revision 1.21 1997/06/22 21:44:41 curt
1058 * Working on intergrating the VRML (subset) parser.
1060 * Revision 1.20 1997/06/21 17:12:53 curt
1061 * Capitalized subdirectory names.
1063 * Revision 1.19 1997/06/18 04:10:31 curt
1064 * A couple more runway tweaks ...
1066 * Revision 1.18 1997/06/18 02:21:24 curt
1067 * Hacked in a runway
1069 * Revision 1.17 1997/06/17 16:51:58 curt
1070 * Timer interval stuff now uses gettimeofday() instead of ftime()
1072 * Revision 1.16 1997/06/17 04:19:16 curt
1073 * More timer related tweaks with respect to view direction changes.
1075 * Revision 1.15 1997/06/17 03:41:10 curt
1076 * Nonsignal based interval timing is now working.
1077 * This would be a good time to look at cleaning up the code structure a bit.
1079 * Revision 1.14 1997/06/16 19:32:51 curt
1080 * Starting to add general timer support.
1082 * Revision 1.13 1997/06/02 03:40:06 curt
1083 * A tiny bit more view tweaking.
1085 * Revision 1.12 1997/06/02 03:01:38 curt
1086 * Working on views (side, front, back, transitions, etc.)
1088 * Revision 1.11 1997/05/31 19:16:25 curt
1089 * Elevator trim added.
1091 * Revision 1.10 1997/05/31 04:13:52 curt
1094 * Continuing work on the LaRCsim flight model integration.
1095 * Added some MSFS-like keyboard input handling.
1097 * Revision 1.9 1997/05/30 19:27:01 curt
1098 * The LaRCsim flight model is starting to look like it is working.
1100 * Revision 1.8 1997/05/30 03:54:10 curt
1101 * Made a bit more progress towards integrating the LaRCsim flight model.
1103 * Revision 1.7 1997/05/29 22:39:49 curt
1104 * Working on incorporating the LaRCsim flight model.
1106 * Revision 1.6 1997/05/29 12:31:39 curt
1107 * Minor tweaks, moving towards general flight model integration.
1109 * Revision 1.5 1997/05/29 02:33:23 curt
1110 * Updated to reflect changing interfaces in other "modules."
1112 * Revision 1.4 1997/05/27 17:44:31 curt
1113 * Renamed & rearranged variables and routines. Added some initial simple
1114 * timer/alarm routines so the flight model can be updated on a regular
1117 * Revision 1.3 1997/05/23 15:40:25 curt
1118 * Added GNU copyright headers.
1121 * Revision 1.2 1997/05/23 00:35:12 curt
1122 * Trying to get fog to work ...
1124 * Revision 1.1 1997/05/21 15:57:51 curt
1125 * Renamed due to added GLUT support.
1127 * Revision 1.3 1997/05/19 18:22:42 curt
1128 * Parameter tweaking ... starting to stub in fog support.
1130 * Revision 1.2 1997/05/17 00:17:34 curt
1131 * Trying to stub in support for standard OpenGL.
1133 * Revision 1.1 1997/05/16 16:05:52 curt