]> git.mxchange.org Git - flightgear.git/blob - Main/GLUTmain.c
Working on scene rendering order and options.
[flightgear.git] / Main / GLUTmain.c
1 /**************************************************************************
2  * GLUTmain.c -- top level sim routines
3  *
4  * Written by Curtis Olson for OpenGL, started May 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  * $Id$
23  * (Log is kept at end of this file)
24  **************************************************************************/
25
26
27 #ifdef WIN32
28 #  include <windows.h>                     
29 #endif
30
31 #include <GL/glut.h>
32 #include "../XGL/xgl.h"
33 #include <stdio.h>
34
35 #include "GLUTkey.h"
36 #include "fg_init.h"
37 #include "views.h"
38
39 #include "../Include/constants.h"
40 #include "../Include/general.h"
41
42 #include "../Aircraft/aircraft.h"
43 #include "../Cockpit/cockpit.h"
44 #include "../Joystick/joystick.h"
45 #include "../Math/fg_geodesy.h"
46 #include "../Math/mat3.h"
47 #include "../Math/polar.h"
48 #include "../Scenery/mesh.h"
49 #include "../Scenery/moon.h"
50 #include "../Scenery/scenery.h"
51 #include "../Scenery/sky.h"
52 #include "../Scenery/stars.h"
53 #include "../Scenery/sun.h"
54 #include "../Time/fg_time.h"
55 #include "../Time/fg_timer.h"
56 #include "../Time/sunpos.h"
57 #include "../Weather/weather.h"
58
59
60 /* This is a record containing global housekeeping information */
61 struct fgGENERAL general;
62
63 /* view parameters */
64 static GLfloat win_ratio = 1.0;
65
66 /* fog color */
67 static GLfloat fgFogColor[4] =   {0.65, 0.65, 0.85, 1.0};
68
69 /* temporary hack */
70 /* pointer to scenery structure */
71 /* static GLint scenery, runway; */
72
73 double Simtime;
74
75 /* Another hack */
76 int use_signals = 0;
77
78 /* Yet another hack. This one used by the HUD code. Michele */
79 int show_hud;
80
81
82 /**************************************************************************
83  * fgInitVisuals() -- Initialize various GL/view parameters
84  **************************************************************************/
85
86 static void fgInitVisuals() {
87     struct fgLIGHT *l;
88     struct fgTIME *t;
89     struct fgWEATHER *w;
90
91     l = &cur_light_params;
92     t = &cur_time_params;
93     w = &current_weather;
94
95     
96     /* xglDisable( GL_DITHER ); */
97
98     /* If enabled, normal vectors specified with glNormal are scaled
99        to unit length after transformation.  See glNormal. */
100     xglEnable( GL_NORMALIZE );
101
102     xglEnable( GL_LIGHTING );
103     xglEnable( GL_LIGHT0 );
104     xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
105
106     xglShadeModel( GL_FLAT ); /* xglShadeModel( GL_SMOOTH ); */
107
108     xglEnable( GL_FOG );
109     xglFogi (GL_FOG_MODE, GL_LINEAR);
110     /* xglFogf (GL_FOG_START, 1.0); */
111     xglFogf (GL_FOG_END, w->visibility);
112     xglFogfv (GL_FOG_COLOR, fgFogColor);
113     /* xglFogf (GL_FOG_DENSITY, w->visibility); */
114     /* xglHint (GL_FOG_HINT, GL_FASTEST); */
115
116     /* initial screen color */
117     xglClearColor(0.0, 0.0, 0.0, 1.0);
118 }
119
120
121 /**************************************************************************
122  * Update the view volume, position, and orientation
123  **************************************************************************/
124
125 static void fgUpdateViewParams() {
126     struct fgFLIGHT *f;
127     struct fgLIGHT *l;
128     struct fgTIME *t;
129     struct fgVIEW *v;
130
131     double x_2, x_4, x_8, x_10;
132     double light, ambient, diffuse, sky_brightness;
133     /* if the 4th field is 0.0, this specifies a direction ... */
134     /* clear color (sky) */
135     GLfloat sky_color[4] = {0.60, 0.60, 0.90, 1.0};
136     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
137
138     f = &current_aircraft.flight;
139     l = &cur_light_params;
140     t = &cur_time_params;
141     v = &current_view;
142
143     fgViewUpdate(f, v);
144
145     /* Tell GL we are about to modify the projection parameters */
146     xglMatrixMode(GL_PROJECTION);
147     xglLoadIdentity();
148     gluPerspective(55.0, 1.0/win_ratio, 1.0, 200000.0);
149
150     xglMatrixMode(GL_MODELVIEW);
151     xglLoadIdentity();
152     
153     /* set up our view volume */
154     gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
155                v->view_pos.x + v->view_forward[0], 
156                v->view_pos.y + v->view_forward[1], 
157                v->view_pos.z + v->view_forward[2],
158                v->view_up[0], v->view_up[1], v->view_up[2]);
159
160     /* set the sun position */
161     xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
162
163     /* calculate lighting parameters based on sun's relative angle to
164      * local up */
165     /* ya kind'a have to plot this to see the magic */
166
167     /* x = t->sun_angle^8 */
168     x_2 = l->sun_angle * l->sun_angle;
169     x_4 = x_2 * x_2;
170     x_8 = x_4 * x_4;
171     x_10 = x_8 * x_2;
172
173     light = pow(1.1, -x_10 / 30.0);
174     ambient = 0.3 * light;
175     diffuse = 0.9 * light;
176
177     sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
178
179     /* sky_brightness = 0.15; */ /* to force a dark sky (for testing) */
180
181     if ( ambient < 0.1 ) { ambient = 0.1; }
182     if ( diffuse < 0.0 ) { diffuse = 0.0; }
183
184     if ( sky_brightness < 0.0 ) { sky_brightness = 0.0; }
185
186     l->scene_ambient[0] = white[0] * ambient;
187     l->scene_ambient[1] = white[1] * ambient;
188     l->scene_ambient[2] = white[2] * ambient;
189
190     l->scene_diffuse[0] = white[0] * diffuse;
191     l->scene_diffuse[1] = white[1] * diffuse;
192     l->scene_diffuse[2] = white[2] * diffuse;
193
194     /* set lighting parameters */
195     xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
196     xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
197
198     /* set fog color */
199     l->scene_fog[0] = fgFogColor[0] * (ambient + diffuse);
200     l->scene_fog[1] = fgFogColor[1] * (ambient + diffuse);
201     l->scene_fog[2] = fgFogColor[2] * (ambient + diffuse);
202     l->scene_fog[3] = fgFogColor[3];
203     xglFogfv (GL_FOG_COLOR, l->scene_fog);
204
205     /* set sky color */
206     l->scene_clear[0] = sky_color[0] * sky_brightness;
207     l->scene_clear[1] = sky_color[1] * sky_brightness;
208     l->scene_clear[2] = sky_color[2] * sky_brightness;
209     l->scene_clear[3] = sky_color[3];
210
211     xglClearColor(l->scene_clear[0], l->scene_clear[1], 
212                   l->scene_clear[2], l->scene_clear[3]);
213 }
214
215
216 /**************************************************************************
217  * Update all Visuals (redraws anything graphics related)
218  **************************************************************************/
219
220 static void fgUpdateVisuals( void ) {
221     struct fgTIME *t;
222     struct fgVIEW *v;
223     double angle;
224     static double lastAstroUpdate = 0;
225
226     t = &cur_time_params;
227     v = &current_view;
228
229     /* update view volume parameters */
230     fgUpdateViewParams();
231
232     xglClear( GL_DEPTH_BUFFER_BIT /* | GL_COLOR_BUFFER_BIT */ );
233
234     /* Tell GL we are switching to model view parameters */
235     xglMatrixMode(GL_MODELVIEW);
236     /* xglLoadIdentity(); */
237
238     /* draw sky */
239     xglDisable( GL_DEPTH_TEST );
240     xglDisable( GL_LIGHTING );
241     xglDisable( GL_CULL_FACE );
242     xglShadeModel( GL_SMOOTH );
243     fgSkyRender();
244
245     /* a hack: Force sun and moon position to be updated on an hourly basis */
246     if (((t->gst - lastAstroUpdate) > 1) || (t->gst < lastAstroUpdate)) {
247         lastAstroUpdate = t->gst;
248         fgSunInit();
249         fgMoonInit();
250     }
251
252     /* setup transformation for drawing astronomical objects */
253     xglPushMatrix();
254     /* Translate to view position */
255     xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
256     /* Rotate based on gst (side real time) */
257     angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
258     /* printf("Rotating astro objects by %.2f degrees\n",angle); */
259     xglRotatef( angle, 0.0, 0.0, -1.0 );
260
261     /* draw stars and planets */
262     xglDisable( GL_FOG );
263     fgStarsRender();
264
265     /* draw the sun */
266     fgSunRender();
267
268     /* render the moon */
269     xglEnable( GL_LIGHTING );
270     xglEnable( GL_CULL_FACE );
271     fgMoonRender();
272
273     xglPopMatrix();
274
275     /* draw scenery */
276     xglShadeModel( GL_FLAT ); 
277     xglEnable( GL_DEPTH_TEST );
278     xglEnable( GL_FOG );
279     fgSceneryRender();
280
281     /* display HUD */
282     /* if( show_hud )
283         fgCockpitUpdate(); */
284
285     #ifdef GLUT
286       xglutSwapBuffers();
287     #endif
288 }
289
290
291 /**************************************************************************
292  * Update internal time dependent calculations (i.e. flight model)
293  **************************************************************************/
294
295 void fgUpdateTimeDepCalcs(int multi_loop) {
296     struct fgFLIGHT *f;
297     struct fgTIME *t;
298     struct fgVIEW *v;
299     int i;
300
301     f = &current_aircraft.flight;
302     t = &cur_time_params;
303     v = &current_view;
304
305     /* update the flight model */
306     if ( multi_loop < 0 ) {
307         multi_loop = DEFAULT_MULTILOOP;
308     }
309
310     /* printf("updating flight model x %d\n", multi_loop); */
311     fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
312
313     /* refresh shared sun position and sun_vec */
314     fgUpdateSunPos(scenery.center);
315
316     /* update the view angle */
317     for ( i = 0; i < multi_loop; i++ ) {
318         if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
319             v->view_offset = v->goal_view_offset;
320             break;
321         } else {
322             /* move v->view_offset towards v->goal_view_offset */
323             if ( v->goal_view_offset > v->view_offset ) {
324                 if ( v->goal_view_offset - v->view_offset < FG_PI ) {
325                     v->view_offset += 0.01;
326                 } else {
327                     v->view_offset -= 0.01;
328                 }
329             } else {
330                 if ( v->view_offset - v->goal_view_offset < FG_PI ) {
331                     v->view_offset -= 0.01;
332                 } else {
333                     v->view_offset += 0.01;
334                 }
335             }
336             if ( v->view_offset > FG_2PI ) {
337                 v->view_offset -= FG_2PI;
338             } else if ( v->view_offset < 0 ) {
339                 v->view_offset += FG_2PI;
340             }
341         }
342     }
343 }
344
345
346 void fgInitTimeDepCalcs() {
347     /* initialize timer */
348
349 #ifdef USE_ITIMER
350     fgTimerInit( 1.0 / DEFAULT_TIMER_HZ, fgUpdateTimeDepCalcs );
351 #endif USE_ITIMER
352
353 }
354
355
356 /**************************************************************************
357  * Scenery management routines
358  **************************************************************************/
359
360 /* static void fgSceneryInit_OLD() { */
361     /* make scenery */
362 /*     scenery = fgSceneryCompile_OLD();
363     runway = fgRunwayHack_OLD(0.69, 53.07);
364 } */
365
366
367 /* create the scenery */
368 /* GLint fgSceneryCompile_OLD() {
369     GLint scenery;
370
371     scenery = mesh2GL(mesh_ptr_OLD);
372
373     return(scenery);
374 }
375 */
376
377 /* hack in a runway */
378 /* GLint fgRunwayHack_OLD(double width, double length) {
379     static GLfloat concrete[4] = { 0.5, 0.5, 0.5, 1.0 };
380     static GLfloat line[4]     = { 0.9, 0.9, 0.9, 1.0 };
381     int i;
382     int num_lines = 16;
383     float line_len, line_width_2, cur_pos;
384
385     runway = xglGenLists(1);
386     xglNewList(runway, GL_COMPILE);
387     */
388     /* draw concrete */
389 /*    xglBegin(GL_POLYGON);
390     xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete );
391     xglNormal3f(0.0, 0.0, 1.0);
392
393     xglVertex3d( 0.0,   -width/2.0, 0.0);
394     xglVertex3d( 0.0,    width/2.0, 0.0);
395     xglVertex3d(length,  width/2.0, 0.0);
396     xglVertex3d(length, -width/2.0, 0.0);
397     xglEnd();
398     */
399     /* draw center line */
400 /*    xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line );
401     line_len = length / ( 2 * num_lines + 1);
402     printf("line_len = %.3f\n", line_len);
403     line_width_2 = 0.02;
404     cur_pos = line_len;
405     for ( i = 0; i < num_lines; i++ ) {
406         xglBegin(GL_POLYGON);
407         xglVertex3d( cur_pos, -line_width_2, 0.005);
408         xglVertex3d( cur_pos,  line_width_2, 0.005);
409         cur_pos += line_len;
410         xglVertex3d( cur_pos,  line_width_2, 0.005);
411         xglVertex3d( cur_pos, -line_width_2, 0.005);
412         cur_pos += line_len;
413         xglEnd();
414     }
415
416     xglEndList();
417
418     return(runway);
419 }
420 */
421
422 /* draw the scenery */
423 /*static void fgSceneryDraw_OLD() {
424     static float z = 32.35;
425
426     xglPushMatrix();
427
428     xglCallList(scenery);
429
430     printf("*** Drawing runway at %.2f\n", z);
431
432     xglTranslatef( -398391.28, 120070.41, 32.35);
433     xglRotatef(170.0, 0.0, 0.0, 1.0);
434     xglCallList(runway);
435
436     xglPopMatrix();
437 }
438 */
439
440 /* What should we do when we have nothing else to do?  How about get
441  * ready for the next move and update the display? */
442 static void fgMainLoop( void ) {
443     static int remainder = 0;
444     int elapsed, multi_loop;
445     double cur_elev;
446     double joy_x, joy_y;
447     int joy_b1, joy_b2;
448     struct fgAIRCRAFT *a;
449     struct fgFLIGHT *f;
450     struct fgTIME *t;
451
452     a = &current_aircraft;
453     f = &a->flight;
454     t = &cur_time_params;
455
456     /* update "time" */
457     fgTimeUpdate(f, t);
458
459     /* Read joystick */
460     /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
461     printf( "Joystick X %f  Y %f  B1 %d  B2 %d\n",  
462             joy_x, joy_y, joy_b1, joy_b2 );
463     fgElevSet( -joy_y );
464     fgAileronSet( joy_x ); */
465
466     /* update the weather for our current position */
467     fgWeatherUpdate(FG_Longitude * RAD_TO_ARCSEC, 
468                     FG_Latitude * RAD_TO_ARCSEC, 
469                     FG_Altitude * FEET_TO_METER);
470
471     /* Calculate model iterations needed */
472     elapsed = fgGetTimeInterval();
473     printf("Time interval is = %d, previous remainder is = %d\n", elapsed, 
474            remainder);
475     printf("--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed);
476     elapsed += remainder;
477
478     multi_loop = ((float)elapsed * 0.001) * DEFAULT_MODEL_HZ;
479     remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
480     printf("Model iterations needed = %d, new remainder = %d\n", multi_loop, 
481            remainder);
482
483     if ( ! use_signals ) {
484         /* flight model */
485         fgUpdateTimeDepCalcs(multi_loop);
486     }
487
488     /* I'm just sticking this here for now, it should probably move 
489      * eventually */
490     cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC, 
491                                FG_Latitude  * RAD_TO_ARCSEC);
492     printf("Ground elevation is %.2f meters here.\n", cur_elev);
493     /* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
494
495     if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
496         /* set this here, otherwise if we set runway height above our
497            current height we get a really nasty bounce. */
498         FG_Runway_altitude = FG_Altitude - 3.758099;
499
500         /* now set aircraft altitude above ground */
501         FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
502         printf("<*> resetting altitude to %.0f meters\n", 
503                FG_Altitude * FEET_TO_METER);
504     }
505
506     fgAircraftOutputCurrent(a);
507
508     /* redraw display */
509     fgUpdateVisuals();
510 }
511
512
513 /**************************************************************************
514  * Handle new window size or exposure
515  **************************************************************************/
516
517 static void fgReshape( int width, int height ) {
518     /* Do this so we can call fgReshape(0,0) ourselves without having to know
519      * what the values of width & height are. */
520     if ( (height > 0) && (width > 0) ) {
521         win_ratio = (GLfloat) height / (GLfloat) width;
522     }
523
524     /* Inform gl of our view window size */
525     xglViewport(0, 0, (GLint)width, (GLint)height);
526
527     fgUpdateViewParams();
528     
529     /* xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); */
530 }
531
532
533 /**************************************************************************
534  * Main ...
535  **************************************************************************/
536
537 int main( int argc, char *argv[] ) {
538     struct fgFLIGHT *f;
539
540     f = &current_aircraft.flight;
541
542     printf("Flight Gear: prototype version %s\n\n", VERSION);
543
544     /**********************************************************************
545      * Initialize the Window/Graphics environment.
546      **********************************************************************/
547
548     #ifdef GLUT
549       /* initialize GLUT */
550       xglutInit(&argc, argv);
551
552       /* Define Display Parameters */
553       xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
554
555       /* Define initial window size */
556       xglutInitWindowSize(640, 480);
557
558       /* Initialize windows */
559       xglutCreateWindow("Flight Gear");
560     #endif
561
562     /* This is the general house keeping init routine */
563     fgInitGeneral();
564
565     /* This is the top level init routine which calls all the other
566      * subsystem initialization routines.  If you are adding a
567      * subsystem to flight gear, its initialization call should
568      * located in this routine.*/
569     fgInitSubsystems();
570
571     /* setup view parameters, only makes GL calls */
572     fgInitVisuals();
573
574     if ( use_signals ) {
575         /* init timer routines, signals, etc.  Arrange for an alarm
576            signal to be generated, etc. */
577         fgInitTimeDepCalcs();
578     }
579
580    /**********************************************************************
581      * Initialize the Event Handlers.
582      **********************************************************************/
583
584     #ifdef GLUT
585       /* call fgReshape() on window resizes */
586       xglutReshapeFunc( fgReshape );
587
588       /* call key() on keyboard event */
589       xglutKeyboardFunc( GLUTkey );
590       glutSpecialFunc( GLUTspecialkey );
591
592       /* call fgMainLoop() whenever there is nothing else to do */
593       xglutIdleFunc( fgMainLoop );
594
595       /* draw the scene */
596       xglutDisplayFunc( fgUpdateVisuals );
597
598       /* pass control off to the GLUT event handler */
599       glutMainLoop();
600     #endif
601
602     return(0);
603 }
604
605
606 #ifdef NO_PRINTF
607   #include <stdarg.h>
608   int printf (const char *format, ...) {
609   }
610 #endif
611
612
613 /* $Log$
614 /* Revision 1.36  1997/12/19 16:44:57  curt
615 /* Working on scene rendering order and options.
616 /*
617  * Revision 1.35  1997/12/18 23:32:32  curt
618  * First stab at sky dome actually starting to look reasonable. :-)
619  *
620  * Revision 1.34  1997/12/17 23:13:34  curt
621  * Began working on rendering a sky.
622  *
623  * Revision 1.33  1997/12/15 23:54:45  curt
624  * Add xgl wrappers for debugging.
625  * Generate terrain normals on the fly.
626  *
627  * Revision 1.32  1997/12/15 20:59:08  curt
628  * Misc. tweaks.
629  *
630  * Revision 1.31  1997/12/12 21:41:25  curt
631  * More light/material property tweaking ... still a ways off.
632  *
633  * Revision 1.30  1997/12/12 19:52:47  curt
634  * Working on lightling and material properties.
635  *
636  * Revision 1.29  1997/12/11 04:43:54  curt
637  * Fixed sun vector and lighting problems.  I thing the moon is now lit
638  * correctly.
639  *
640  * Revision 1.28  1997/12/10 22:37:45  curt
641  * Prepended "fg" on the name of all global structures that didn't have it yet.
642  * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
643  *
644  * Revision 1.27  1997/12/09 05:11:54  curt
645  * Working on tweaking lighting.
646  *
647  * Revision 1.26  1997/12/09 04:25:29  curt
648  * Working on adding a global lighting params structure.
649  *
650  * Revision 1.25  1997/12/08 22:54:09  curt
651  * Enabled GL_CULL_FACE.
652  *
653  * Revision 1.24  1997/11/25 19:25:32  curt
654  * Changes to integrate Durk's moon/sun code updates + clean up.
655  *
656  * Revision 1.23  1997/11/15 18:16:34  curt
657  * minor tweaks.
658  *
659  * Revision 1.22  1997/10/30 12:38:41  curt
660  * Working on new scenery subsystem.
661  *
662  * Revision 1.21  1997/09/23 00:29:38  curt
663  * Tweaks to get things to compile with gcc-win32.
664  *
665  * Revision 1.20  1997/09/22 14:44:19  curt
666  * Continuing to try to align stars correctly.
667  *
668  * Revision 1.19  1997/09/18 16:20:08  curt
669  * At dusk/dawn add/remove stars in stages.
670  *
671  * Revision 1.18  1997/09/16 22:14:51  curt
672  * Tweaked time of day lighting equations.  Don't draw stars during the day.
673  *
674  * Revision 1.17  1997/09/16 15:50:29  curt
675  * Working on star alignment and time issues.
676  *
677  * Revision 1.16  1997/09/13 02:00:06  curt
678  * Mostly working on stars and generating sidereal time for accurate star
679  * placement.
680  *
681  * Revision 1.15  1997/09/05 14:17:27  curt
682  * More tweaking with stars.
683  *
684  * Revision 1.14  1997/09/05 01:35:53  curt
685  * Working on getting stars right.
686  *
687  * Revision 1.13  1997/09/04 02:17:34  curt
688  * Shufflin' stuff.
689  *
690  * Revision 1.12  1997/08/27 21:32:24  curt
691  * Restructured view calculation code.  Added stars.
692  *
693  * Revision 1.11  1997/08/27 03:30:16  curt
694  * Changed naming scheme of basic shared structures.
695  *
696  * Revision 1.10  1997/08/25 20:27:22  curt
697  * Merged in initial HUD and Joystick code.
698  *
699  * Revision 1.9  1997/08/22 21:34:39  curt
700  * Doing a bit of reorganizing and house cleaning.
701  *
702  * Revision 1.8  1997/08/19 23:55:03  curt
703  * Worked on better simulating real lighting.
704  *
705  * Revision 1.7  1997/08/16 12:22:38  curt
706  * Working on improving the lighting/shading.
707  *
708  * Revision 1.6  1997/08/13 20:24:56  curt
709  * Changes due to changing sunpos interface.
710  *
711  * Revision 1.5  1997/08/06 21:08:32  curt
712  * Sun position now *really* works (I think) ... I still have sun time warping
713  * code in place, probably should remove it soon.
714  *
715  * Revision 1.4  1997/08/06 15:41:26  curt
716  * Working on correct sun position.
717  *
718  * Revision 1.3  1997/08/06 00:24:22  curt
719  * Working on correct real time sun lighting.
720  *
721  * Revision 1.2  1997/08/04 20:25:15  curt
722  * Organizational tweaking.
723  *
724  * Revision 1.1  1997/08/02 18:45:00  curt
725  * Renamed GLmain.c GLUTmain.c
726  *
727  * Revision 1.43  1997/08/02 16:23:47  curt
728  * Misc. tweaks.
729  *
730  * Revision 1.42  1997/08/01 19:43:33  curt
731  * Making progress with coordinate system overhaul.
732  *
733  * Revision 1.41  1997/07/31 22:52:37  curt
734  * Working on redoing internal coordinate systems & scenery transformations.
735  *
736  * Revision 1.40  1997/07/30 16:12:42  curt
737  * Moved fg_random routines from Util/ to Math/
738  *
739  * Revision 1.39  1997/07/21 14:45:01  curt
740  * Minor tweaks.
741  *
742  * Revision 1.38  1997/07/19 23:04:47  curt
743  * Added an initial weather section.
744  *
745  * Revision 1.37  1997/07/19 22:34:02  curt
746  * Moved PI definitions to ../constants.h
747  * Moved random() stuff to ../Utils/ and renamed fg_random()
748  *
749  * Revision 1.36  1997/07/18 23:41:25  curt
750  * Tweaks for building with Cygnus Win32 compiler.
751  *
752  * Revision 1.35  1997/07/18 14:28:34  curt
753  * Hacked in some support for wind/turbulence.
754  *
755  * Revision 1.34  1997/07/16 20:04:48  curt
756  * Minor tweaks to aid Win32 port.
757  *
758  * Revision 1.33  1997/07/12 03:50:20  curt
759  * Added an #include <Windows32/Base.h> to help compiling for Win32
760  *
761  * Revision 1.32  1997/07/11 03:23:18  curt
762  * Solved some scenery display/orientation problems.  Still have a positioning
763  * (or transformation?) problem.
764  *
765  * Revision 1.31  1997/07/11 01:29:58  curt
766  * More tweaking of terrian floor.
767  *
768  * Revision 1.30  1997/07/10 04:26:37  curt
769  * We now can interpolated ground elevation for any position in the grid.  We
770  * can use this to enforce a "hard" ground.  We still need to enforce some
771  * bounds checking so that we don't try to lookup data points outside the
772  * grid data set.
773  *
774  * Revision 1.29  1997/07/09 21:31:12  curt
775  * Working on making the ground "hard."
776  *
777  * Revision 1.28  1997/07/08 18:20:12  curt
778  * Working on establishing a hard ground.
779  *
780  * Revision 1.27  1997/07/07 20:59:49  curt
781  * Working on scenery transformations to enable us to fly fluidly over the
782  * poles with no discontinuity/distortion in scenery.
783  *
784  * Revision 1.26  1997/07/05 20:43:34  curt
785  * renamed mat3 directory to Math so we could add other math related routines.
786  *
787  * Revision 1.25  1997/06/29 21:19:17  curt
788  * Working on scenery management system.
789  *
790  * Revision 1.24  1997/06/26 22:14:53  curt
791  * Beginning work on a scenery management system.
792  *
793  * Revision 1.23  1997/06/26 19:08:33  curt
794  * Restructuring make, adding automatic "make dep" support.
795  *
796  * Revision 1.22  1997/06/25 15:39:47  curt
797  * Minor changes to compile with rsxnt/win32.
798  *
799  * Revision 1.21  1997/06/22 21:44:41  curt
800  * Working on intergrating the VRML (subset) parser.
801  *
802  * Revision 1.20  1997/06/21 17:12:53  curt
803  * Capitalized subdirectory names.
804  *
805  * Revision 1.19  1997/06/18 04:10:31  curt
806  * A couple more runway tweaks ...
807  *
808  * Revision 1.18  1997/06/18 02:21:24  curt
809  * Hacked in a runway
810  *
811  * Revision 1.17  1997/06/17 16:51:58  curt
812  * Timer interval stuff now uses gettimeofday() instead of ftime()
813  *
814  * Revision 1.16  1997/06/17 04:19:16  curt
815  * More timer related tweaks with respect to view direction changes.
816  *
817  * Revision 1.15  1997/06/17 03:41:10  curt
818  * Nonsignal based interval timing is now working.
819  * This would be a good time to look at cleaning up the code structure a bit.
820  *
821  * Revision 1.14  1997/06/16 19:32:51  curt
822  * Starting to add general timer support.
823  *
824  * Revision 1.13  1997/06/02 03:40:06  curt
825  * A tiny bit more view tweaking.
826  *
827  * Revision 1.12  1997/06/02 03:01:38  curt
828  * Working on views (side, front, back, transitions, etc.)
829  *
830  * Revision 1.11  1997/05/31 19:16:25  curt
831  * Elevator trim added.
832  *
833  * Revision 1.10  1997/05/31 04:13:52  curt
834  * WE CAN NOW FLY!!!
835  *
836  * Continuing work on the LaRCsim flight model integration.
837  * Added some MSFS-like keyboard input handling.
838  *
839  * Revision 1.9  1997/05/30 19:27:01  curt
840  * The LaRCsim flight model is starting to look like it is working.
841  *
842  * Revision 1.8  1997/05/30 03:54:10  curt
843  * Made a bit more progress towards integrating the LaRCsim flight model.
844  *
845  * Revision 1.7  1997/05/29 22:39:49  curt
846  * Working on incorporating the LaRCsim flight model.
847  *
848  * Revision 1.6  1997/05/29 12:31:39  curt
849  * Minor tweaks, moving towards general flight model integration.
850  *
851  * Revision 1.5  1997/05/29 02:33:23  curt
852  * Updated to reflect changing interfaces in other "modules."
853  *
854  * Revision 1.4  1997/05/27 17:44:31  curt
855  * Renamed & rearranged variables and routines.   Added some initial simple
856  * timer/alarm routines so the flight model can be updated on a regular 
857  * interval.
858  *
859  * Revision 1.3  1997/05/23 15:40:25  curt
860  * Added GNU copyright headers.
861  * Fog now works!
862  *
863  * Revision 1.2  1997/05/23 00:35:12  curt
864  * Trying to get fog to work ...
865  *
866  * Revision 1.1  1997/05/21 15:57:51  curt
867  * Renamed due to added GLUT support.
868  *
869  * Revision 1.3  1997/05/19 18:22:42  curt
870  * Parameter tweaking ... starting to stub in fog support.
871  *
872  * Revision 1.2  1997/05/17 00:17:34  curt
873  * Trying to stub in support for standard OpenGL.
874  *
875  * Revision 1.1  1997/05/16 16:05:52  curt
876  * Initial revision.
877  *
878  */