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" // Naked,HUD,Panel,Chase,Tower...
162 // Only naked view and HUD are implemented at this time
164 Option logfileOption = { 'x',
167 "Debug log file name"
171 #define OptsDefined 6
172 Option *CmdLineOptions[ OptsDefined ] = {
181 const char *DefaultRootDir = "\\Flightgear";
182 const char *DefaultAircraft = "Navion.acf";
183 const char *DefaultDebuglog = "fgdebug.log";
184 const int DefaultViewMode = HUD_VIEW;
186 // Debug defaults handled in fg_debug.c
188 /**************************************************************************
189 * fgInitVisuals() -- Initialize various GL/view parameters
190 **************************************************************************/
192 static void fgInitVisuals( void ) {
196 l = &cur_light_params;
197 w = ¤t_weather;
199 /* xglDisable( GL_DITHER ); */
201 /* If enabled, normal vectors specified with glNormal are scaled
202 to unit length after transformation. See glNormal. */
203 xglEnable( GL_NORMALIZE );
205 xglEnable( GL_LIGHTING );
206 xglEnable( GL_LIGHT0 );
207 xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
209 xglFogi (GL_FOG_MODE, GL_LINEAR);
210 /* xglFogf (GL_FOG_START, 1.0); */
211 xglFogf (GL_FOG_END, w->visibility);
212 /* xglFogf (GL_FOG_DENSITY, w->visibility); */
213 xglHint (GL_FOG_HINT, GL_NICEST /* GL_FASTEST */ );
215 /* draw wire frame */
216 /* xglPolygonMode(GL_FRONT_AND_BACK,GL_LINE); */
220 /**************************************************************************
221 * Update the view volume, position, and orientation
222 **************************************************************************/
224 static void fgUpdateViewParams( void ) {
230 f = current_aircraft.flight;
231 l = &cur_light_params;
232 // t = &cur_time_params;
235 fgViewUpdate(f, v, l);
237 if (displayInstruments)
239 xglViewport(0, (GLint)(winHeight / 2 ) , (GLint)winWidth, (GLint)winHeight / 2);
240 /* Tell GL we are about to modify the projection parameters */
241 xglMatrixMode(GL_PROJECTION);
243 gluPerspective(55.0, 2.0/win_ratio, 1.0, 100000.0);
247 xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
248 /* Tell GL we are about to modify the projection parameters */
249 xglMatrixMode(GL_PROJECTION);
251 gluPerspective(55.0, 1.0/win_ratio, 1.0, 100000.0);
254 xglMatrixMode(GL_MODELVIEW);
257 /* set up our view volume (default) */
258 gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
259 v->view_pos.x + v->view_forward[0],
260 v->view_pos.y + v->view_forward[1],
261 v->view_pos.z + v->view_forward[2],
262 v->view_up[0], v->view_up[1], v->view_up[2]);
264 /* lock view horizontally towards sun (testing) */
265 /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
266 v->view_pos.x + v->surface_to_sun[0],
267 v->view_pos.y + v->surface_to_sun[1],
268 v->view_pos.z + v->surface_to_sun[2],
269 v->view_up[0], v->view_up[1], v->view_up[2]); */
271 /* lock view horizontally towards south (testing) */
272 /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
273 v->view_pos.x + v->surface_south[0],
274 v->view_pos.y + v->surface_south[1],
275 v->view_pos.z + v->surface_south[2],
276 v->view_up[0], v->view_up[1], v->view_up[2]); */
278 /* set the sun position */
279 xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
283 /*************************************************************************
284 * Draw a basic instrument panel
285 ************************************************************************/
286 static void fgUpdateInstrViewParams( void ) {
287 xglViewport(0, 0 , (GLint)winWidth, (GLint)winHeight / 2);
289 xglMatrixMode(GL_PROJECTION);
293 gluOrtho2D(0, 640, 0, 480);
294 xglMatrixMode(GL_MODELVIEW);
298 xglColor3f(1.0, 1.0, 1.0);
301 xglDisable(GL_DEPTH_TEST);
302 xglDisable(GL_LIGHTING);
305 xglColor3f (0.5, 0.5, 0.5);
308 xglVertex2f(0.0, 0.00);
309 xglVertex2f(0.0, 480.0);
310 xglVertex2f(640.0,480.0);
311 xglVertex2f(640.0, 0.0);
314 xglRectf(0.0,0.0, 640, 480);
315 xglEnable(GL_DEPTH_TEST);
316 xglEnable(GL_LIGHTING);
317 xglMatrixMode(GL_PROJECTION);
319 xglMatrixMode(GL_MODELVIEW);
324 /**************************************************************************
325 * Update all Visuals (redraws anything graphics related)
326 **************************************************************************/
328 static void fgRenderFrame( void ) {
333 GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
335 l = &cur_light_params;
336 t = &cur_time_params;
339 /* update view volume parameters */
340 fgUpdateViewParams();
342 xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
344 /* Tell GL we are switching to model view parameters */
345 xglMatrixMode(GL_MODELVIEW);
346 /* xglLoadIdentity(); */
349 xglDisable( GL_DEPTH_TEST );
350 xglDisable( GL_LIGHTING );
351 xglDisable( GL_CULL_FACE );
352 xglDisable( GL_FOG );
353 xglShadeModel( GL_SMOOTH );
356 /* setup transformation for drawing astronomical objects */
358 /* Translate to view position */
359 xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
360 /* Rotate based on gst (sidereal time) */
361 angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
362 /* printf("Rotating astro objects by %.2f degrees\n",angle); */
363 xglRotatef( angle, 0.0, 0.0, -1.0 );
365 /* draw stars and planets */
372 /* render the moon */
373 xglEnable( GL_LIGHTING );
374 /* set lighting parameters */
375 xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
376 xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
377 xglEnable( GL_CULL_FACE );
379 /* Let's try some blending technique's (Durk)*/
381 glBlendFunc(GL_ONE, GL_ONE);
388 xglShadeModel( /* GL_FLAT */ GL_SMOOTH );
389 xglEnable( GL_DEPTH_TEST );
391 xglFogfv (GL_FOG_COLOR, l->fog_color);
392 /* set lighting parameters */
393 xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
394 xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
396 /* fgSceneryRender(); */
403 /* display instruments */
404 if (displayInstruments) {
405 fgUpdateInstrViewParams();
412 /**************************************************************************
413 * Update internal time dependent calculations (i.e. flight model)
414 **************************************************************************/
416 void fgUpdateTimeDepCalcs(int multi_loop) {
422 f = current_aircraft.flight;
423 t = &cur_time_params;
426 /* update the flight model */
427 if ( multi_loop < 0 ) {
428 multi_loop = DEFAULT_MULTILOOP;
431 /* printf("updating flight model x %d\n", multi_loop); */
432 fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
434 /* update the view angle */
435 for ( i = 0; i < multi_loop; i++ ) {
436 if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
437 v->view_offset = v->goal_view_offset;
440 /* move v->view_offset towards v->goal_view_offset */
441 if ( v->goal_view_offset > v->view_offset ) {
442 if ( v->goal_view_offset - v->view_offset < FG_PI ) {
443 v->view_offset += 0.01;
445 v->view_offset -= 0.01;
448 if ( v->view_offset - v->goal_view_offset < FG_PI ) {
449 v->view_offset -= 0.01;
451 v->view_offset += 0.01;
454 if ( v->view_offset > FG_2PI ) {
455 v->view_offset -= FG_2PI;
456 } else if ( v->view_offset < 0 ) {
457 v->view_offset += FG_2PI;
464 void fgInitTimeDepCalcs( void ) {
465 /* initialize timer */
468 fgTimerInit( 1.0 / DEFAULT_TIMER_HZ, fgUpdateTimeDepCalcs );
474 /**************************************************************************
475 * Scenery management routines
476 **************************************************************************/
478 /* static void fgSceneryInit_OLD() { */
480 /* scenery = fgSceneryCompile_OLD();
481 runway = fgRunwayHack_OLD(0.69, 53.07);
485 /* create the scenery */
486 /* GLint fgSceneryCompile_OLD() {
489 scenery = mesh2GL(mesh_ptr_OLD);
495 /* hack in a runway */
496 /* GLint fgRunwayHack_OLD(double width, double length) {
497 static GLfloat concrete[4] = { 0.5, 0.5, 0.5, 1.0 };
498 static GLfloat line[4] = { 0.9, 0.9, 0.9, 1.0 };
501 float line_len, line_width_2, cur_pos;
503 runway = xglGenLists(1);
504 xglNewList(runway, GL_COMPILE);
507 /* xglBegin(GL_POLYGON);
508 xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete );
509 xglNormal3f(0.0, 0.0, 1.0);
511 xglVertex3d( 0.0, -width/2.0, 0.0);
512 xglVertex3d( 0.0, width/2.0, 0.0);
513 xglVertex3d(length, width/2.0, 0.0);
514 xglVertex3d(length, -width/2.0, 0.0);
517 /* draw center line */
518 /* xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line );
519 line_len = length / ( 2 * num_lines + 1);
520 printf("line_len = %.3f\n", line_len);
523 for ( i = 0; i < num_lines; i++ ) {
524 xglBegin(GL_POLYGON);
525 xglVertex3d( cur_pos, -line_width_2, 0.005);
526 xglVertex3d( cur_pos, line_width_2, 0.005);
528 xglVertex3d( cur_pos, line_width_2, 0.005);
529 xglVertex3d( cur_pos, -line_width_2, 0.005);
540 /* draw the scenery */
541 /*static void fgSceneryDraw_OLD() {
542 static float z = 32.35;
546 xglCallList(scenery);
548 printf("*** Drawing runway at %.2f\n", z);
550 xglTranslatef( -398391.28, 120070.41, 32.35);
551 xglRotatef(170.0, 0.0, 0.0, 1.0);
559 /* What should we do when we have nothing else to do? How about get
560 * ready for the next move and update the display? */
561 static void fgMainLoop( void ) {
562 static int remainder = 0;
563 int elapsed, multi_loop;
565 /* double joy_x, joy_y; */
566 /* int joy_b1, joy_b2; */
571 fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
572 fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
574 a = ¤t_aircraft;
576 t = &cur_time_params;
582 /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
583 printf( "Joystick X %f Y %f B1 %d B2 %d\n",
584 joy_x, joy_y, joy_b1, joy_b2 );
586 fgAileronSet( joy_x ); */
588 /* Calculate model iterations needed */
589 elapsed = fgGetTimeInterval();
590 fgPrintf( FG_ALL, FG_BULK,
591 "Time interval is = %d, previous remainder is = %d\n",
593 fgPrintf( FG_ALL, FG_BULK,
594 "--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed);
595 elapsed += remainder;
597 multi_loop = (int)(((float)elapsed * 0.001) * DEFAULT_MODEL_HZ);
598 remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
599 fgPrintf( FG_ALL, FG_BULK,
600 "Model iterations needed = %d, new remainder = %d\n",
601 multi_loop, remainder);
603 /* Run flight model */
604 if ( ! use_signals ) {
606 fgUpdateTimeDepCalcs(multi_loop);
609 /* I'm just sticking this here for now, it should probably move
611 /* cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
612 FG_Latitude * RAD_TO_ARCSEC); */
613 /* there is no ground collision detection really, so for now I
614 * just hard code the ground elevation to be 0 */
617 /* printf("Ground elevation is %.2f meters here.\n", cur_elev); */
618 /* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
620 if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
621 /* set this here, otherwise if we set runway height above our
622 current height we get a really nasty bounce. */
623 FG_Runway_altitude = FG_Altitude - 3.758099;
625 /* now set aircraft altitude above ground */
626 FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
627 fgPrintf( FG_ALL, FG_BULK, "<*> resetting altitude to %.0f meters\n",
628 FG_Altitude * FEET_TO_METER);
631 fgAircraftOutputCurrent(a);
633 /* see if we need to load any new scenery tiles */
636 /* Process/manage pending events */
642 fgPrintf( FG_ALL, FG_DEBUG, "\n");
646 /**************************************************************************
647 * Handle new window size or exposure
648 **************************************************************************/
650 static void fgReshape( int width, int height ) {
651 /* Do this so we can call fgReshape(0,0) ourselves without having to know
652 * what the values of width & height are. */
653 if ( (height > 0) && (width > 0) ) {
654 win_ratio = (GLfloat) height / (GLfloat) width;
660 /* Inform gl of our view window size (now handled elsewhere) */
661 /* xglViewport(0, 0, (GLint)width, (GLint)height); */
663 fgUpdateViewParams();
665 /* xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); */
669 /**************************************************************************
671 **************************************************************************/
673 int main( int argc, char *argv[] ) {
675 int parse_result; // Used in command line argument.
677 f = current_aircraft.flight;
678 // First things first... We must have startup options dealt with.
681 #define VERSION "src-32A"
683 printf("Flight Gear: Version %s\n\n", VERSION);
685 /*********************************************************************
686 * Initialize the Window/Graphics environment.
687 **********************************************************************/
689 /* initialize GLUT */
690 xglutInit(&argc, argv);
692 /* Define Display Parameters */
693 xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
695 /* Define initial window size */
696 xglutInitWindowSize(640, 480);
698 /* Initialize windows */
699 xglutCreateWindow("Flight Gear");
701 // xglutInit above will extract all non-general program command line.
702 // We only need wory about our own.
704 parse_result = getargs( argc, argv, OptsDefined, CmdLineOptions, NULL);
706 switch( parse_result ) {
711 print_desc( OptsDefined, CmdLineOptions );
716 printf( "Flight Gear: Command line invalid.");
720 // Deal with the effects of options no set by manipulating the command
721 // line, or possibly set to invalid states.
723 if(( viewArg >= 0) && (viewArg <= 1)) {
724 show_hud = viewArg; // For now view_mode TRUE - no HUD, else show_hud.
726 show_hud = DefaultViewMode;
729 // All other command line option responses are handled in the various
730 // initialization routines (or ignored if not implemented.
732 // This is the general house keeping init routine. It initializes the
733 // debug trail scheme and then any other stuff.
735 if( !fgInitGeneral()) {
737 // This is the top level init routine which calls all the other
738 // subsystem initialization routines. If you are adding a
739 // subsystem to flight gear, its initialization call should
740 // located in this routine.
741 if( !fgInitSubsystems()) {
743 // setup view parameters, only makes GL calls
747 /* init timer routines, signals, etc. Arrange for an alarm
748 signal to be generated, etc. */
749 fgInitTimeDepCalcs();
752 /**********************************************************
753 * Initialize the GLUT Event Handlers.
754 **********************************************************/
756 // call fgReshape() on window resizes
757 xglutReshapeFunc( fgReshape );
759 // call key() on keyboard event
760 xglutKeyboardFunc( GLUTkey );
761 glutSpecialFunc( GLUTspecialkey );
763 // call fgMainLoop() whenever there is
764 // nothing else to do
765 xglutIdleFunc( fgMainLoop );
768 xglutDisplayFunc( fgRenderFrame );
770 // pass control off to the GLUT event handler
773 } // End if subsystems initialize ok
774 } // End if general initializations went ok
776 if( fg_DebugOutput ) {
777 fclose( fg_DebugOutput );
785 void __eprintf( void ) {
791 /* Revision 1.62 1998/02/16 13:39:42 curt
792 /* Miscellaneous weekend tweaks. Fixed? a cache problem that caused whole
793 /* tiles to occasionally be missing.
795 * Revision 1.61 1998/02/12 21:59:46 curt
796 * Incorporated code changes contributed by Charlie Hotchkiss
797 * <chotchkiss@namg.us.anritsu.com>
799 * Revision 1.60 1998/02/11 02:50:40 curt
802 * Revision 1.59 1998/02/09 22:56:54 curt
803 * Removed "depend" files from cvs control. Other minor make tweaks.
805 * Revision 1.58 1998/02/09 15:07:49 curt
808 * Revision 1.57 1998/02/07 15:29:40 curt
809 * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
810 * <chotchkiss@namg.us.anritsu.com>
812 * Revision 1.56 1998/02/03 23:20:23 curt
813 * Lots of little tweaks to fix various consistency problems discovered by
814 * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
815 * passed arguments along to the real printf(). Also incorporated HUD changes
816 * by Michele America.
818 * Revision 1.55 1998/02/02 20:53:58 curt
819 * Incorporated Durk's changes.
821 * Revision 1.54 1998/01/31 00:43:10 curt
822 * Added MetroWorks patches from Carmen Volpe.
824 * Revision 1.53 1998/01/27 18:35:54 curt
827 * Revision 1.52 1998/01/27 00:47:56 curt
828 * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
829 * system and commandline/config file processing code.
831 * Revision 1.51 1998/01/26 15:57:05 curt
832 * Tweaks for dynamic scenery development.
834 * Revision 1.50 1998/01/19 19:27:07 curt
835 * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
836 * This should simplify things tremendously.
838 * Revision 1.49 1998/01/19 18:40:31 curt
839 * Tons of little changes to clean up the code and to remove fatal errors
840 * when building with the c++ compiler.
842 * Revision 1.48 1998/01/19 18:35:46 curt
843 * Minor tweaks and fixes for cygwin32.
845 * Revision 1.47 1998/01/13 00:23:08 curt
846 * Initial changes to support loading and management of scenery tiles. Note,
847 * there's still a fair amount of work left to be done.
849 * Revision 1.46 1998/01/08 02:22:06 curt
850 * Beginning to integrate Tile management subsystem.
852 * Revision 1.45 1998/01/07 03:18:55 curt
853 * Moved astronomical stuff from .../Src/Scenery to .../Src/Astro/
855 * Revision 1.44 1997/12/30 22:22:31 curt
856 * Further integration of event manager.
858 * Revision 1.43 1997/12/30 20:47:43 curt
859 * Integrated new event manager with subsystem initializations.
861 * Revision 1.42 1997/12/30 16:36:47 curt
862 * Merged in Durk's changes ...
864 * Revision 1.41 1997/12/30 13:06:56 curt
865 * A couple lighting tweaks ...
867 * Revision 1.40 1997/12/30 01:38:37 curt
868 * Switched back to per vertex normals and smooth shading for terrain.
870 * Revision 1.39 1997/12/22 23:45:45 curt
871 * First stab at sunset/sunrise sky glow effects.
873 * Revision 1.38 1997/12/22 04:14:28 curt
874 * Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
876 * Revision 1.37 1997/12/19 23:34:03 curt
877 * Lot's of tweaking with sky rendering and lighting.
879 * Revision 1.36 1997/12/19 16:44:57 curt
880 * Working on scene rendering order and options.
882 * Revision 1.35 1997/12/18 23:32:32 curt
883 * First stab at sky dome actually starting to look reasonable. :-)
885 * Revision 1.34 1997/12/17 23:13:34 curt
886 * Began working on rendering a sky.
888 * Revision 1.33 1997/12/15 23:54:45 curt
889 * Add xgl wrappers for debugging.
890 * Generate terrain normals on the fly.
892 * Revision 1.32 1997/12/15 20:59:08 curt
895 * Revision 1.31 1997/12/12 21:41:25 curt
896 * More light/material property tweaking ... still a ways off.
898 * Revision 1.30 1997/12/12 19:52:47 curt
899 * Working on lightling and material properties.
901 * Revision 1.29 1997/12/11 04:43:54 curt
902 * Fixed sun vector and lighting problems. I thing the moon is now lit
905 * Revision 1.28 1997/12/10 22:37:45 curt
906 * Prepended "fg" on the name of all global structures that didn't have it yet.
907 * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
909 * Revision 1.27 1997/12/09 05:11:54 curt
910 * Working on tweaking lighting.
912 * Revision 1.26 1997/12/09 04:25:29 curt
913 * Working on adding a global lighting params structure.
915 * Revision 1.25 1997/12/08 22:54:09 curt
916 * Enabled GL_CULL_FACE.
918 * Revision 1.24 1997/11/25 19:25:32 curt
919 * Changes to integrate Durk's moon/sun code updates + clean up.
921 * Revision 1.23 1997/11/15 18:16:34 curt
924 * Revision 1.22 1997/10/30 12:38:41 curt
925 * Working on new scenery subsystem.
927 * Revision 1.21 1997/09/23 00:29:38 curt
928 * Tweaks to get things to compile with gcc-win32.
930 * Revision 1.20 1997/09/22 14:44:19 curt
931 * Continuing to try to align stars correctly.
933 * Revision 1.19 1997/09/18 16:20:08 curt
934 * At dusk/dawn add/remove stars in stages.
936 * Revision 1.18 1997/09/16 22:14:51 curt
937 * Tweaked time of day lighting equations. Don't draw stars during the day.
939 * Revision 1.17 1997/09/16 15:50:29 curt
940 * Working on star alignment and time issues.
942 * Revision 1.16 1997/09/13 02:00:06 curt
943 * Mostly working on stars and generating sidereal time for accurate star
946 * Revision 1.15 1997/09/05 14:17:27 curt
947 * More tweaking with stars.
949 * Revision 1.14 1997/09/05 01:35:53 curt
950 * Working on getting stars right.
952 * Revision 1.13 1997/09/04 02:17:34 curt
955 * Revision 1.12 1997/08/27 21:32:24 curt
956 * Restructured view calculation code. Added stars.
958 * Revision 1.11 1997/08/27 03:30:16 curt
959 * Changed naming scheme of basic shared structures.
961 * Revision 1.10 1997/08/25 20:27:22 curt
962 * Merged in initial HUD and Joystick code.
964 * Revision 1.9 1997/08/22 21:34:39 curt
965 * Doing a bit of reorganizing and house cleaning.
967 * Revision 1.8 1997/08/19 23:55:03 curt
968 * Worked on better simulating real lighting.
970 * Revision 1.7 1997/08/16 12:22:38 curt
971 * Working on improving the lighting/shading.
973 * Revision 1.6 1997/08/13 20:24:56 curt
974 * Changes due to changing sunpos interface.
976 * Revision 1.5 1997/08/06 21:08:32 curt
977 * Sun position now *really* works (I think) ... I still have sun time warping
978 * code in place, probably should remove it soon.
980 * Revision 1.4 1997/08/06 15:41:26 curt
981 * Working on correct sun position.
983 * Revision 1.3 1997/08/06 00:24:22 curt
984 * Working on correct real time sun lighting.
986 * Revision 1.2 1997/08/04 20:25:15 curt
987 * Organizational tweaking.
989 * Revision 1.1 1997/08/02 18:45:00 curt
990 * Renamed GLmain.c GLUTmain.c
992 * Revision 1.43 1997/08/02 16:23:47 curt
995 * Revision 1.42 1997/08/01 19:43:33 curt
996 * Making progress with coordinate system overhaul.
998 * Revision 1.41 1997/07/31 22:52:37 curt
999 * Working on redoing internal coordinate systems & scenery transformations.
1001 * Revision 1.40 1997/07/30 16:12:42 curt
1002 * Moved fg_random routines from Util/ to Math/
1004 * Revision 1.39 1997/07/21 14:45:01 curt
1007 * Revision 1.38 1997/07/19 23:04:47 curt
1008 * Added an initial weather section.
1010 * Revision 1.37 1997/07/19 22:34:02 curt
1011 * Moved PI definitions to ../constants.h
1012 * Moved random() stuff to ../Utils/ and renamed fg_random()
1014 * Revision 1.36 1997/07/18 23:41:25 curt
1015 * Tweaks for building with Cygnus Win32 compiler.
1017 * Revision 1.35 1997/07/18 14:28:34 curt
1018 * Hacked in some support for wind/turbulence.
1020 * Revision 1.34 1997/07/16 20:04:48 curt
1021 * Minor tweaks to aid Win32 port.
1023 * Revision 1.33 1997/07/12 03:50:20 curt
1024 * Added an #include <Windows32/Base.h> to help compiling for Win32
1026 * Revision 1.32 1997/07/11 03:23:18 curt
1027 * Solved some scenery display/orientation problems. Still have a positioning
1028 * (or transformation?) problem.
1030 * Revision 1.31 1997/07/11 01:29:58 curt
1031 * More tweaking of terrian floor.
1033 * Revision 1.30 1997/07/10 04:26:37 curt
1034 * We now can interpolated ground elevation for any position in the grid. We
1035 * can use this to enforce a "hard" ground. We still need to enforce some
1036 * bounds checking so that we don't try to lookup data points outside the
1039 * Revision 1.29 1997/07/09 21:31:12 curt
1040 * Working on making the ground "hard."
1042 * Revision 1.28 1997/07/08 18:20:12 curt
1043 * Working on establishing a hard ground.
1045 * Revision 1.27 1997/07/07 20:59:49 curt
1046 * Working on scenery transformations to enable us to fly fluidly over the
1047 * poles with no discontinuity/distortion in scenery.
1049 * Revision 1.26 1997/07/05 20:43:34 curt
1050 * renamed mat3 directory to Math so we could add other math related routines.
1052 * Revision 1.25 1997/06/29 21:19:17 curt
1053 * Working on scenery management system.
1055 * Revision 1.24 1997/06/26 22:14:53 curt
1056 * Beginning work on a scenery management system.
1058 * Revision 1.23 1997/06/26 19:08:33 curt
1059 * Restructuring make, adding automatic "make dep" support.
1061 * Revision 1.22 1997/06/25 15:39:47 curt
1062 * Minor changes to compile with rsxnt/win32.
1064 * Revision 1.21 1997/06/22 21:44:41 curt
1065 * Working on intergrating the VRML (subset) parser.
1067 * Revision 1.20 1997/06/21 17:12:53 curt
1068 * Capitalized subdirectory names.
1070 * Revision 1.19 1997/06/18 04:10:31 curt
1071 * A couple more runway tweaks ...
1073 * Revision 1.18 1997/06/18 02:21:24 curt
1074 * Hacked in a runway
1076 * Revision 1.17 1997/06/17 16:51:58 curt
1077 * Timer interval stuff now uses gettimeofday() instead of ftime()
1079 * Revision 1.16 1997/06/17 04:19:16 curt
1080 * More timer related tweaks with respect to view direction changes.
1082 * Revision 1.15 1997/06/17 03:41:10 curt
1083 * Nonsignal based interval timing is now working.
1084 * This would be a good time to look at cleaning up the code structure a bit.
1086 * Revision 1.14 1997/06/16 19:32:51 curt
1087 * Starting to add general timer support.
1089 * Revision 1.13 1997/06/02 03:40:06 curt
1090 * A tiny bit more view tweaking.
1092 * Revision 1.12 1997/06/02 03:01:38 curt
1093 * Working on views (side, front, back, transitions, etc.)
1095 * Revision 1.11 1997/05/31 19:16:25 curt
1096 * Elevator trim added.
1098 * Revision 1.10 1997/05/31 04:13:52 curt
1101 * Continuing work on the LaRCsim flight model integration.
1102 * Added some MSFS-like keyboard input handling.
1104 * Revision 1.9 1997/05/30 19:27:01 curt
1105 * The LaRCsim flight model is starting to look like it is working.
1107 * Revision 1.8 1997/05/30 03:54:10 curt
1108 * Made a bit more progress towards integrating the LaRCsim flight model.
1110 * Revision 1.7 1997/05/29 22:39:49 curt
1111 * Working on incorporating the LaRCsim flight model.
1113 * Revision 1.6 1997/05/29 12:31:39 curt
1114 * Minor tweaks, moving towards general flight model integration.
1116 * Revision 1.5 1997/05/29 02:33:23 curt
1117 * Updated to reflect changing interfaces in other "modules."
1119 * Revision 1.4 1997/05/27 17:44:31 curt
1120 * Renamed & rearranged variables and routines. Added some initial simple
1121 * timer/alarm routines so the flight model can be updated on a regular
1124 * Revision 1.3 1997/05/23 15:40:25 curt
1125 * Added GNU copyright headers.
1128 * Revision 1.2 1997/05/23 00:35:12 curt
1129 * Trying to get fog to work ...
1131 * Revision 1.1 1997/05/21 15:57:51 curt
1132 * Renamed due to added GLUT support.
1134 * Revision 1.3 1997/05/19 18:22:42 curt
1135 * Parameter tweaking ... starting to stub in fog support.
1137 * Revision 1.2 1997/05/17 00:17:34 curt
1138 * Trying to stub in support for standard OpenGL.
1140 * Revision 1.1 1997/05/16 16:05:52 curt