2 // GLUTmain.cxx -- 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)
43 #include <Include/fg_constants.h> // for VERSION
44 #include <Include/general.h>
46 #include <Aircraft/aircraft.h>
47 #include <Astro/moon.hxx>
48 #include <Astro/planets.hxx>
49 #include <Astro/sky.hxx>
50 #include <Astro/stars.hxx>
51 #include <Astro/sun.hxx>
52 #include <Cockpit/cockpit.hxx>
53 #include <Debug/fg_debug.h>
54 #include <Joystick/joystick.h>
55 #include <Math/fg_geodesy.h>
56 #include <Math/mat3.h>
57 #include <Math/polar3d.h>
58 #include <Scenery/scenery.hxx>
59 #include <Scenery/tilemgr.hxx>
60 #include <Time/event.hxx>
61 #include <Time/fg_time.hxx>
62 #include <Time/fg_timer.hxx>
63 #include <Time/sunpos.hxx>
64 #include <Weather/weather.h>
66 #include "GLUTkey.hxx"
67 #include "fg_init.hxx"
68 #include "options.hxx"
72 // This is a record containing global housekeeping information
76 static GLfloat win_ratio = 1.0;
77 static GLint winWidth, winHeight;
82 // Yet another other hack. Used for my prototype instrument code. (Durk)
83 int displayInstruments;
86 // The following defines flight gear options. Because glutlib will also
87 // want to parse its own options, those options must not be included here
88 // or they will get parsed by the main program option parser. Hence case
89 // is significant for any option added that might be in conflict with
92 // glutlib parses for:
94 // -direct (invalid in Win32)
98 // -indirect (invalid in Win32)
101 // Note that glutlib depends upon strings while this program's
102 // option parser wants only initial characters followed by numbers
105 const char *fg_cmdargopts = "a:c:Hhp:r:v:x:?";
108 // -a aircraftfilename aircraft start over ride
109 // -c0x0000 - 0xffffffff debug class setting
110 // H,h.? help on command line use (does not need Option struct)
112 // -r flightgear root path to program support files
113 // -v0 -v1 initial view mode (hud/no_hud currently)
114 // -xlogpathname debug logfile name
116 // Defaults in arguments to indicate not set on command line.
117 // Program defaults set variables from constants if neither command
118 // options or environmental variables effect values.
121 char acArgbuf [ MAXPATH + 1] = "\0";
122 int debugArgValue = -2;
123 int priorityArgValue = -1;
124 char rootArgbuf [ MAXPATH + 1] = "\0";
126 char logArgbuf [ MAXPATH + 1] = "\0";
128 // There is a reason for defining the option structs by name and then
129 // creating an array of pointers to options. C++ is unfriendly to
130 // initializing arrays of objects that are not built in types. Always
131 // look forward. (Besides, you can follow what is going on better and
132 // add or modify with greater security. -ch
134 Option aircraftOption = { 'a',
137 "Startup aircraft pathname override"
139 Option debugOption = { 'c',
140 OPT_LHEX, // Long int (32 bits)
144 Option priorityOption = { 'p',
147 "Debug priority Threshold"
149 Option rootOption = { 'r',
152 "Root directory for execution"
154 Option hudOption = { 'v',
157 "View mode start" // Naked,HUD,Panel,Chase,Tower...
160 // Only naked view and HUD are implemented at this time
161 Option logfileOption = { 'x',
164 "Debug log file name"
167 #define OptsDefined 6
168 Option *CmdLineOptions[ OptsDefined ] = {
177 const char *DefaultRootDir = "\\Flightgear";
178 const char *DefaultAircraft = "Navion.acf";
179 const char *DefaultDebuglog = "fgdebug.log";
180 const int DefaultViewMode = HUD_VIEW;
183 // Debug defaults handled in fg_debug.c
185 // fgInitVisuals() -- Initialize various GL/view parameters
186 static void fgInitVisuals( void ) {
191 l = &cur_light_params;
192 o = ¤t_options;
193 w = ¤t_weather;
195 // Go full screen if requested ...
196 if ( o->fullscreen ) {
200 // If enabled, normal vectors specified with glNormal are scaled
201 // to unit length after transformation. See glNormal.
202 xglEnable( GL_NORMALIZE );
204 xglEnable( GL_LIGHTING );
205 xglEnable( GL_LIGHT0 );
206 xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
208 xglFogi (GL_FOG_MODE, GL_LINEAR);
209 xglFogf (GL_FOG_START, w->visibility / 1000000.0 );
210 xglFogf (GL_FOG_END, w->visibility);
211 // xglFogf (GL_FOG_DENSITY, w->visibility);
212 xglHint (GL_FOG_HINT, GL_NICEST /* GL_FASTEST */ );
214 if ( o->wireframe ) {
216 xglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
221 // Update the view volume, position, and orientation
222 static void fgUpdateViewParams( void ) {
227 f = current_aircraft.flight;
228 l = &cur_light_params;
231 fgViewUpdate(f, v, l);
233 if (displayInstruments) {
234 xglViewport( 0, (GLint)(winHeight / 2 ) ,
235 (GLint)winWidth, (GLint)winHeight / 2 );
236 // Tell GL we are about to modify the projection parameters
237 xglMatrixMode(GL_PROJECTION);
239 gluPerspective(65.0, 2.0/win_ratio, 1.0, 100000.0);
241 xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
242 // Tell GL we are about to modify the projection parameters
243 xglMatrixMode(GL_PROJECTION);
245 gluPerspective(65.0, 1.0/win_ratio, 10.0, 100000.0);
248 xglMatrixMode(GL_MODELVIEW);
251 // set up our view volume (default)
252 gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
253 v->view_pos.x + v->view_forward[0],
254 v->view_pos.y + v->view_forward[1],
255 v->view_pos.z + v->view_forward[2],
256 v->view_up[0], v->view_up[1], v->view_up[2]);
258 // look almost straight up (testing and eclipse watching)
259 /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
260 v->view_pos.x + v->view_up[0] + .001,
261 v->view_pos.y + v->view_up[1] + .001,
262 v->view_pos.z + v->view_up[2] + .001,
263 v->view_up[0], v->view_up[1], v->view_up[2]); */
265 // lock view horizontally towards sun (testing)
266 /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
267 v->view_pos.x + v->surface_to_sun[0],
268 v->view_pos.y + v->surface_to_sun[1],
269 v->view_pos.z + v->surface_to_sun[2],
270 v->view_up[0], v->view_up[1], v->view_up[2]); */
272 // lock view horizontally towards south (testing)
273 /* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
274 v->view_pos.x + v->surface_south[0],
275 v->view_pos.y + v->surface_south[1],
276 v->view_pos.z + v->surface_south[2],
277 v->view_up[0], v->view_up[1], v->view_up[2]); */
279 // set the sun position
280 xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
284 // Draw a basic instrument panel
285 static void fgUpdateInstrViewParams( void ) {
286 xglViewport(0, 0 , (GLint)winWidth, (GLint)winHeight / 2);
288 xglMatrixMode(GL_PROJECTION);
292 gluOrtho2D(0, 640, 0, 480);
293 xglMatrixMode(GL_MODELVIEW);
297 xglColor3f(1.0, 1.0, 1.0);
300 xglDisable(GL_DEPTH_TEST);
301 xglDisable(GL_LIGHTING);
304 xglColor3f (0.5, 0.5, 0.5);
307 xglVertex2f(0.0, 0.00);
308 xglVertex2f(0.0, 480.0);
309 xglVertex2f(640.0,480.0);
310 xglVertex2f(640.0, 0.0);
313 xglRectf(0.0,0.0, 640, 480);
314 xglEnable(GL_DEPTH_TEST);
315 xglEnable(GL_LIGHTING);
316 xglMatrixMode(GL_PROJECTION);
318 xglMatrixMode(GL_MODELVIEW);
323 // Update all Visuals (redraws anything graphics related)
324 static void fgRenderFrame( void ) {
330 GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
331 GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
332 GLfloat color[4] = { 0.54, 0.44, 0.29, 1.0 };
334 l = &cur_light_params;
335 o = ¤t_options;
336 t = &cur_time_params;
339 // update view volume parameters
340 fgUpdateViewParams();
343 glClearColor(black[0], black[1], black[2], black[3]);
345 glClearColor(l->sky_color[0], l->sky_color[1],
346 l->sky_color[2], l->sky_color[3]);
348 xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
350 // Tell GL we are switching to model view parameters
351 xglMatrixMode(GL_MODELVIEW);
352 // xglLoadIdentity();
355 xglDisable( GL_DEPTH_TEST );
356 xglDisable( GL_LIGHTING );
357 xglDisable( GL_CULL_FACE );
358 xglDisable( GL_FOG );
359 xglShadeModel( GL_SMOOTH );
364 // setup transformation for drawing astronomical objects
366 // Translate to view position
367 xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
368 // Rotate based on gst (sidereal time)
369 angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
370 // printf("Rotating astro objects by %.2f degrees\n",angle);
371 xglRotatef( angle, 0.0, 0.0, -1.0 );
373 // draw stars and planets
381 xglEnable( GL_LIGHTING );
382 // set lighting parameters
383 xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
384 xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
385 xglEnable( GL_CULL_FACE );
387 // Let's try some blending technique's (Durk)
389 glBlendFunc(GL_ONE, GL_ONE);
397 xglShadeModel( GL_SMOOTH );
399 xglShadeModel( GL_FLAT );
401 xglEnable( GL_DEPTH_TEST );
404 xglFogfv (GL_FOG_COLOR, l->fog_color);
406 // set lighting parameters
407 xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
408 xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
411 // texture parameters
412 xglEnable( GL_TEXTURE_2D );
413 xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ;
414 xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
415 xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ) ;
416 xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
417 GL_LINEAR /* GL_LINEAR_MIPMAP_LINEAR */ ) ;
418 xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
419 xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ;
420 // set base color (I don't think this is doing anything here)
421 xglMaterialfv (GL_FRONT, GL_AMBIENT, white);
422 xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
424 xglDisable( GL_TEXTURE_2D );
425 xglMaterialfv (GL_FRONT, GL_AMBIENT, color);
426 xglMaterialfv (GL_FRONT, GL_DIFFUSE, color);
431 xglDisable( GL_TEXTURE_2D );
434 if( o->hud_status ) {
438 // display instruments
439 if (displayInstruments) {
440 fgUpdateInstrViewParams();
447 // Update internal time dependent calculations (i.e. flight model)
448 void fgUpdateTimeDepCalcs(int multi_loop) {
454 f = current_aircraft.flight;
455 t = &cur_time_params;
458 // update the flight model
459 if ( multi_loop < 0 ) {
460 multi_loop = DEFAULT_MULTILOOP;
463 // printf("updating flight model x %d\n", multi_loop);
464 fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
466 // update the view angle
467 for ( i = 0; i < multi_loop; i++ ) {
468 if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
469 v->view_offset = v->goal_view_offset;
472 // move v->view_offset towards v->goal_view_offset
473 if ( v->goal_view_offset > v->view_offset ) {
474 if ( v->goal_view_offset - v->view_offset < FG_PI ) {
475 v->view_offset += 0.01;
477 v->view_offset -= 0.01;
480 if ( v->view_offset - v->goal_view_offset < FG_PI ) {
481 v->view_offset -= 0.01;
483 v->view_offset += 0.01;
486 if ( v->view_offset > FG_2PI ) {
487 v->view_offset -= FG_2PI;
488 } else if ( v->view_offset < 0 ) {
489 v->view_offset += FG_2PI;
496 void fgInitTimeDepCalcs( void ) {
499 #ifdef HAVE_SETITIMER
500 fgTimerInit( 1.0 / DEFAULT_TIMER_HZ, fgUpdateTimeDepCalcs );
501 #endif HAVE_SETITIMER
506 // What should we do when we have nothing else to do? Let's get ready
507 // for the next move and update the display?
508 static void fgMainLoop( void ) {
513 static int remainder = 0;
514 int elapsed, multi_loop;
518 // double joy_x, joy_y;
519 // int joy_b1, joy_b2;
521 a = ¤t_aircraft;
524 t = &cur_time_params;
526 fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
527 fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
533 /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
534 printf( "Joystick X %f Y %f B1 %d B2 %d\n",
535 joy_x, joy_y, joy_b1, joy_b2 );
537 fgAileronSet( joy_x ); */
539 // Get elapsed time for this past frame
540 elapsed = fgGetTimeInterval();
541 fgPrintf( FG_ALL, FG_BULK,
542 "Time interval is = %d, previous remainder is = %d\n",
545 // Calculate frame rate average
546 if ( elapsed > 0.0 ) {
548 for ( i = FG_FRAME_RATE_HISTORY - 2; i >= 0; i-- ) {
549 accum += g->frames[i];
550 // printf("frame[%d] = %.2f\n", i, g->frames[i]);
551 g->frames[i+1] = g->frames[i];
553 g->frames[0] = 1000.0 / (float)elapsed;
554 // printf("frame[0] = %.2f\n", g->frames[0]);
555 accum += g->frames[0];
556 g->frame_rate = accum / (float)FG_FRAME_RATE_HISTORY;
557 // printf("ave = %.2f\n", g->frame_rate);
560 // Calculate model iterations needed for next frame
561 fgPrintf( FG_ALL, FG_DEBUG,
562 "--> Frame rate is = %.2f\n", g->frame_rate);
563 elapsed += remainder;
565 multi_loop = (int)(((float)elapsed * 0.001) * DEFAULT_MODEL_HZ);
566 remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
567 fgPrintf( FG_ALL, FG_BULK,
568 "Model iterations needed = %d, new remainder = %d\n",
569 multi_loop, remainder);
572 if ( ! use_signals ) {
574 fgUpdateTimeDepCalcs(multi_loop);
577 // I'm just sticking this here for now, it should probably move
579 /* cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
580 FG_Latitude * RAD_TO_ARCSEC); */
581 // there is no ground collision detection really, so for now I
582 // just hard code the ground elevation to be 0 */
585 // printf("Ground elevation is %.2f meters here.\n", cur_elev);
586 // FG_Runway_altitude = cur_elev * METER_TO_FEET;
588 if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
589 // set this here, otherwise if we set runway height above our
590 // current height we get a really nasty bounce.
591 FG_Runway_altitude = FG_Altitude - 3.758099;
593 // now set aircraft altitude above ground
594 FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
595 fgPrintf( FG_ALL, FG_BULK, "<*> resetting altitude to %.0f meters\n",
596 FG_Altitude * FEET_TO_METER);
599 fgAircraftOutputCurrent(a);
601 // see if we need to load any new scenery tiles
604 // Process/manage pending events
610 fgPrintf( FG_ALL, FG_DEBUG, "\n");
614 // Handle new window size or exposure
615 static void fgReshape( int width, int height ) {
616 // Do this so we can call fgReshape(0,0) ourselves without having
617 // to know what the values of width & height are.
618 if ( (height > 0) && (width > 0) ) {
619 win_ratio = (GLfloat) height / (GLfloat) width;
625 // Inform gl of our view window size (now handled elsewhere)
626 // xglViewport(0, 0, (GLint)width, (GLint)height);
627 fgUpdateViewParams();
629 // xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
633 // Initialize GLUT and define a main window
634 int fgGlutInit( int *argc, char **argv ) {
635 // GLUT will extract all glut specific options so later on we only
636 // need wory about our own.
637 xglutInit(argc, argv);
639 // Define Display Parameters
640 xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
642 // Define initial window size
643 xglutInitWindowSize(640, 480);
645 // Initialize windows
646 xglutCreateWindow("Flight Gear");
652 // Initialize GLUT event handlers
653 int fgGlutInitEvents( void ) {
654 // call fgReshape() on window resizes
655 xglutReshapeFunc( fgReshape );
657 // call GLUTkey() on keyboard event
658 xglutKeyboardFunc( GLUTkey );
659 glutSpecialFunc( GLUTspecialkey );
661 // call fgMainLoop() whenever there is
662 // nothing else to do
663 xglutIdleFunc( fgMainLoop );
666 xglutDisplayFunc( fgRenderFrame );
673 int main( int argc, char **argv ) {
675 int result; // Used in command line argument.
677 f = current_aircraft.flight;
680 _control87(MCW_EM, MCW_EM); /* defined in float.h */
683 // Initialize the debugging output system
686 fgPrintf(FG_GENERAL, FG_INFO, "Flight Gear: Version %s\n\n", VERSION);
688 // Initialize the Window/Graphics environment.
689 if( !fgGlutInit(&argc, argv) ) {
690 fgPrintf( FG_GENERAL, FG_EXIT, "GLUT initialization failed ...\n" );
693 // Parse remaining command line options
694 result = current_options.parse(argc, argv);
696 if ( result != FG_OPTIONS_OK ) {
697 // Something must have gone horribly wrong with the command
698 // line parsing or maybe the user just requested help ... :-)
699 current_options.usage();
700 fgPrintf( FG_GENERAL, FG_EXIT, "\nShutting down ...\n");
703 // These are a few miscellaneous things that aren't really
704 // "subsystems" but still need to be initialized.
705 if( !fgInitGeneral()) {
706 fgPrintf( FG_GENERAL, FG_EXIT, "General initializations failed ...\n" );
709 // This is the top level init routine which calls all the other
710 // subsystem initialization routines. If you are adding a
711 // subsystem to flight gear, its initialization call should
712 // located in this routine.
713 if( !fgInitSubsystems()) {
714 fgPrintf( FG_GENERAL, FG_EXIT,
715 "Subsystem initializations failed ...\n" );
718 // setup OpenGL view parameters
722 // init timer routines, signals, etc. Arrange for an alarm
723 // signal to be generated, etc.
724 fgInitTimeDepCalcs();
727 // Initialize the various GLUT Event Handlers.
728 if( !fgGlutInitEvents() ) {
729 fgPrintf( FG_GENERAL, FG_EXIT,
730 "GLUT event handler initialization failed ...\n" );
733 // pass control off to the master GLUT event handler
736 // we never actually get here ... but just in case ... :-)
743 void __eprintf( void ) {
750 // Revision 1.12 1998/05/07 23:14:15 curt
751 // Added "D" key binding to set autopilot heading.
752 // Made frame rate calculation average out over last 10 frames.
753 // Borland C++ floating point exception workaround.
754 // Added a --tile-radius=n option.
756 // Revision 1.11 1998/05/06 03:16:23 curt
757 // Added an averaged global frame rate counter.
758 // Added an option to control tile radius.
760 // Revision 1.10 1998/05/03 00:47:31 curt
761 // Added an option to enable/disable full-screen mode.
763 // Revision 1.9 1998/04/30 12:34:17 curt
764 // Added command line rendering options:
765 // enable/disable fog/haze
766 // specify smooth/flat shading
767 // disable sky blending and just use a solid color
768 // enable wireframe drawing mode
770 // Revision 1.8 1998/04/28 01:20:21 curt
771 // Type-ified fgTIME and fgVIEW.
772 // Added a command line option to disable textures.
774 // Revision 1.7 1998/04/26 05:10:02 curt
775 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
777 // Revision 1.6 1998/04/25 22:06:30 curt
778 // Edited cvs log messages in source files ... bad bad bad!
780 // Revision 1.5 1998/04/25 20:24:01 curt
781 // Cleaned up initialization sequence to eliminate interdependencies
782 // between sun position, lighting, and view position. This creates a
783 // valid single pass initialization path.
785 // Revision 1.4 1998/04/24 14:19:30 curt
788 // Revision 1.3 1998/04/24 00:49:18 curt
789 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
790 // Trying out some different option parsing code.
791 // Some code reorganization.
793 // Revision 1.2 1998/04/22 13:25:41 curt
794 // C++ - ifing the code.
795 // Starting a bit of reorganization of lighting code.
797 // Revision 1.1 1998/04/21 17:02:39 curt
798 // Prepairing for C++ integration.
800 // Revision 1.71 1998/04/18 04:11:26 curt
801 // Moved fg_debug to it's own library, added zlib support.
803 // Revision 1.70 1998/04/14 02:21:02 curt
804 // Incorporated autopilot heading hold contributed by: Jeff Goeke-Smith
805 // <jgoeke@voyager.net>
807 // Revision 1.69 1998/04/08 23:35:34 curt
808 // Tweaks to Gnu automake/autoconf system.
810 // Revision 1.68 1998/04/03 22:09:03 curt
811 // Converting to Gnu autoconf system.
813 // Revision 1.67 1998/03/23 21:24:37 curt
814 // Source code formating tweaks.
816 // Revision 1.66 1998/03/14 00:31:20 curt
817 // Beginning initial terrain texturing experiments.
819 // Revision 1.65 1998/03/09 22:45:57 curt
820 // Minor tweaks for building on sparc platform.
822 // Revision 1.64 1998/02/20 00:16:23 curt
823 // Thursday's tweaks.
825 // Revision 1.63 1998/02/16 16:17:39 curt
828 // Revision 1.62 1998/02/16 13:39:42 curt
829 // Miscellaneous weekend tweaks. Fixed? a cache problem that caused whole
830 // tiles to occasionally be missing.
832 // Revision 1.61 1998/02/12 21:59:46 curt
833 // Incorporated code changes contributed by Charlie Hotchkiss
834 // <chotchkiss@namg.us.anritsu.com>
836 // Revision 1.60 1998/02/11 02:50:40 curt
839 // Revision 1.59 1998/02/09 22:56:54 curt
840 // Removed "depend" files from cvs control. Other minor make tweaks.
842 // Revision 1.58 1998/02/09 15:07:49 curt
845 // Revision 1.57 1998/02/07 15:29:40 curt
846 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
847 // <chotchkiss@namg.us.anritsu.com>
849 // Revision 1.56 1998/02/03 23:20:23 curt
850 // Lots of little tweaks to fix various consistency problems discovered by
851 // Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
852 // passed arguments along to the real printf(). Also incorporated HUD changes
853 // by Michele America.
855 // Revision 1.55 1998/02/02 20:53:58 curt
856 // Incorporated Durk's changes.
858 // Revision 1.54 1998/01/31 00:43:10 curt
859 // Added MetroWorks patches from Carmen Volpe.
861 // Revision 1.53 1998/01/27 18:35:54 curt
864 // Revision 1.52 1998/01/27 00:47:56 curt
865 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
866 // system and commandline/config file processing code.
868 // Revision 1.51 1998/01/26 15:57:05 curt
869 // Tweaks for dynamic scenery development.
871 // Revision 1.50 1998/01/19 19:27:07 curt
872 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
873 // This should simplify things tremendously.
875 // Revision 1.49 1998/01/19 18:40:31 curt
876 // Tons of little changes to clean up the code and to remove fatal errors
877 // when building with the c++ compiler.
879 // Revision 1.48 1998/01/19 18:35:46 curt
880 // Minor tweaks and fixes for cygwin32.
882 // Revision 1.47 1998/01/13 00:23:08 curt
883 // Initial changes to support loading and management of scenery tiles. Note,
884 // there's still a fair amount of work left to be done.
886 // Revision 1.46 1998/01/08 02:22:06 curt
887 // Beginning to integrate Tile management subsystem.
889 // Revision 1.45 1998/01/07 03:18:55 curt
890 // Moved astronomical stuff from .../Src/Scenery to .../Src/Astro/
892 // Revision 1.44 1997/12/30 22:22:31 curt
893 // Further integration of event manager.
895 // Revision 1.43 1997/12/30 20:47:43 curt
896 // Integrated new event manager with subsystem initializations.
898 // Revision 1.42 1997/12/30 16:36:47 curt
899 // Merged in Durk's changes ...
901 // Revision 1.41 1997/12/30 13:06:56 curt
902 // A couple lighting tweaks ...
904 // Revision 1.40 1997/12/30 01:38:37 curt
905 // Switched back to per vertex normals and smooth shading for terrain.
907 // Revision 1.39 1997/12/22 23:45:45 curt
908 // First stab at sunset/sunrise sky glow effects.
910 // Revision 1.38 1997/12/22 04:14:28 curt
911 // Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
913 // Revision 1.37 1997/12/19 23:34:03 curt
914 // Lot's of tweaking with sky rendering and lighting.
916 // Revision 1.36 1997/12/19 16:44:57 curt
917 // Working on scene rendering order and options.
919 // Revision 1.35 1997/12/18 23:32:32 curt
920 // First stab at sky dome actually starting to look reasonable. :-)
922 // Revision 1.34 1997/12/17 23:13:34 curt
923 // Began working on rendering a sky.
925 // Revision 1.33 1997/12/15 23:54:45 curt
926 // Add xgl wrappers for debugging.
927 // Generate terrain normals on the fly.
929 // Revision 1.32 1997/12/15 20:59:08 curt
932 // Revision 1.31 1997/12/12 21:41:25 curt
933 // More light/material property tweaking ... still a ways off.
935 // Revision 1.30 1997/12/12 19:52:47 curt
936 // Working on lightling and material properties.
938 // Revision 1.29 1997/12/11 04:43:54 curt
939 // Fixed sun vector and lighting problems. I thing the moon is now lit
942 // Revision 1.28 1997/12/10 22:37:45 curt
943 // Prepended "fg" on the name of all global structures that didn't have it yet.
944 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
946 // Revision 1.27 1997/12/09 05:11:54 curt
947 // Working on tweaking lighting.
949 // Revision 1.26 1997/12/09 04:25:29 curt
950 // Working on adding a global lighting params structure.
952 // Revision 1.25 1997/12/08 22:54:09 curt
953 // Enabled GL_CULL_FACE.
955 // Revision 1.24 1997/11/25 19:25:32 curt
956 // Changes to integrate Durk's moon/sun code updates + clean up.
958 // Revision 1.23 1997/11/15 18:16:34 curt
961 // Revision 1.22 1997/10/30 12:38:41 curt
962 // Working on new scenery subsystem.
964 // Revision 1.21 1997/09/23 00:29:38 curt
965 // Tweaks to get things to compile with gcc-win32.
967 // Revision 1.20 1997/09/22 14:44:19 curt
968 // Continuing to try to align stars correctly.
970 // Revision 1.19 1997/09/18 16:20:08 curt
971 // At dusk/dawn add/remove stars in stages.
973 // Revision 1.18 1997/09/16 22:14:51 curt
974 // Tweaked time of day lighting equations. Don't draw stars during the day.
976 // Revision 1.17 1997/09/16 15:50:29 curt
977 // Working on star alignment and time issues.
979 // Revision 1.16 1997/09/13 02:00:06 curt
980 // Mostly working on stars and generating sidereal time for accurate star
983 // Revision 1.15 1997/09/05 14:17:27 curt
984 // More tweaking with stars.
986 // Revision 1.14 1997/09/05 01:35:53 curt
987 // Working on getting stars right.
989 // Revision 1.13 1997/09/04 02:17:34 curt
992 // Revision 1.12 1997/08/27 21:32:24 curt
993 // Restructured view calculation code. Added stars.
995 // Revision 1.11 1997/08/27 03:30:16 curt
996 // Changed naming scheme of basic shared structures.
998 // Revision 1.10 1997/08/25 20:27:22 curt
999 // Merged in initial HUD and Joystick code.
1001 // Revision 1.9 1997/08/22 21:34:39 curt
1002 // Doing a bit of reorganizing and house cleaning.
1004 // Revision 1.8 1997/08/19 23:55:03 curt
1005 // Worked on better simulating real lighting.
1007 // Revision 1.7 1997/08/16 12:22:38 curt
1008 // Working on improving the lighting/shading.
1010 // Revision 1.6 1997/08/13 20:24:56 curt
1011 // Changes due to changing sunpos interface.
1013 // Revision 1.5 1997/08/06 21:08:32 curt
1014 // Sun position now really* works (I think) ... I still have sun time warping
1015 // code in place, probably should remove it soon.
1017 // Revision 1.4 1997/08/06 15:41:26 curt
1018 // Working on correct sun position.
1020 // Revision 1.3 1997/08/06 00:24:22 curt
1021 // Working on correct real time sun lighting.
1023 // Revision 1.2 1997/08/04 20:25:15 curt
1024 // Organizational tweaking.
1026 // Revision 1.1 1997/08/02 18:45:00 curt
1027 // Renamed GLmain.c GLUTmain.c
1029 // Revision 1.43 1997/08/02 16:23:47 curt
1032 // Revision 1.42 1997/08/01 19:43:33 curt
1033 // Making progress with coordinate system overhaul.
1035 // Revision 1.41 1997/07/31 22:52:37 curt
1036 // Working on redoing internal coordinate systems & scenery transformations.
1038 // Revision 1.40 1997/07/30 16:12:42 curt
1039 // Moved fg_random routines from Util/ to Math/
1041 // Revision 1.39 1997/07/21 14:45:01 curt
1044 // Revision 1.38 1997/07/19 23:04:47 curt
1045 // Added an initial weather section.
1047 // Revision 1.37 1997/07/19 22:34:02 curt
1048 // Moved PI definitions to ../constants.h
1049 // Moved random() stuff to ../Utils/ and renamed fg_random()
1051 // Revision 1.36 1997/07/18 23:41:25 curt
1052 // Tweaks for building with Cygnus Win32 compiler.
1054 // Revision 1.35 1997/07/18 14:28:34 curt
1055 // Hacked in some support for wind/turbulence.
1057 // Revision 1.34 1997/07/16 20:04:48 curt
1058 // Minor tweaks to aid Win32 port.
1060 // Revision 1.33 1997/07/12 03:50:20 curt
1061 // Added an #include <Windows32/Base.h> to help compiling for Win32
1063 // Revision 1.32 1997/07/11 03:23:18 curt
1064 // Solved some scenery display/orientation problems. Still have a positioning
1065 // (or transformation?) problem.
1067 // Revision 1.31 1997/07/11 01:29:58 curt
1068 // More tweaking of terrian floor.
1070 // Revision 1.30 1997/07/10 04:26:37 curt
1071 // We now can interpolated ground elevation for any position in the grid. We
1072 // can use this to enforce a "hard" ground. We still need to enforce some
1073 // bounds checking so that we don't try to lookup data points outside the
1076 // Revision 1.29 1997/07/09 21:31:12 curt
1077 // Working on making the ground "hard."
1079 // Revision 1.28 1997/07/08 18:20:12 curt
1080 // Working on establishing a hard ground.
1082 // Revision 1.27 1997/07/07 20:59:49 curt
1083 // Working on scenery transformations to enable us to fly fluidly over the
1084 // poles with no discontinuity/distortion in scenery.
1086 // Revision 1.26 1997/07/05 20:43:34 curt
1087 // renamed mat3 directory to Math so we could add other math related routines.
1089 // Revision 1.25 1997/06/29 21:19:17 curt
1090 // Working on scenery management system.
1092 // Revision 1.24 1997/06/26 22:14:53 curt
1093 // Beginning work on a scenery management system.
1095 // Revision 1.23 1997/06/26 19:08:33 curt
1096 // Restructuring make, adding automatic "make dep" support.
1098 // Revision 1.22 1997/06/25 15:39:47 curt
1099 // Minor changes to compile with rsxnt/win32.
1101 // Revision 1.21 1997/06/22 21:44:41 curt
1102 // Working on intergrating the VRML (subset) parser.
1104 // Revision 1.20 1997/06/21 17:12:53 curt
1105 // Capitalized subdirectory names.
1107 // Revision 1.19 1997/06/18 04:10:31 curt
1108 // A couple more runway tweaks ...
1110 // Revision 1.18 1997/06/18 02:21:24 curt
1111 // Hacked in a runway
1113 // Revision 1.17 1997/06/17 16:51:58 curt
1114 // Timer interval stuff now uses gettimeofday() instead of ftime()
1116 // Revision 1.16 1997/06/17 04:19:16 curt
1117 // More timer related tweaks with respect to view direction changes.
1119 // Revision 1.15 1997/06/17 03:41:10 curt
1120 // Nonsignal based interval timing is now working.
1121 // This would be a good time to look at cleaning up the code structure a bit.
1123 // Revision 1.14 1997/06/16 19:32:51 curt
1124 // Starting to add general timer support.
1126 // Revision 1.13 1997/06/02 03:40:06 curt
1127 // A tiny bit more view tweaking.
1129 // Revision 1.12 1997/06/02 03:01:38 curt
1130 // Working on views (side, front, back, transitions, etc.)
1132 // Revision 1.11 1997/05/31 19:16:25 curt
1133 // Elevator trim added.
1135 // Revision 1.10 1997/05/31 04:13:52 curt
1136 // WE CAN NOW FLY!!!
1138 // Continuing work on the LaRCsim flight model integration.
1139 // Added some MSFS-like keyboard input handling.
1141 // Revision 1.9 1997/05/30 19:27:01 curt
1142 // The LaRCsim flight model is starting to look like it is working.
1144 // Revision 1.8 1997/05/30 03:54:10 curt
1145 // Made a bit more progress towards integrating the LaRCsim flight model.
1147 // Revision 1.7 1997/05/29 22:39:49 curt
1148 // Working on incorporating the LaRCsim flight model.
1150 // Revision 1.6 1997/05/29 12:31:39 curt
1151 // Minor tweaks, moving towards general flight model integration.
1153 // Revision 1.5 1997/05/29 02:33:23 curt
1154 // Updated to reflect changing interfaces in other "modules."
1156 // Revision 1.4 1997/05/27 17:44:31 curt
1157 // Renamed & rearranged variables and routines. Added some initial simple
1158 // timer/alarm routines so the flight model can be updated on a regular
1161 // Revision 1.3 1997/05/23 15:40:25 curt
1162 // Added GNU copyright headers.
1165 // Revision 1.2 1997/05/23 00:35:12 curt
1166 // Trying to get fog to work ...
1168 // Revision 1.1 1997/05/21 15:57:51 curt
1169 // Renamed due to added GLUT support.
1171 // Revision 1.3 1997/05/19 18:22:42 curt
1172 // Parameter tweaking ... starting to stub in fog support.
1174 // Revision 1.2 1997/05/17 00:17:34 curt
1175 // Trying to stub in support for standard OpenGL.
1177 // Revision 1.1 1997/05/16 16:05:52 curt
1178 // Initial revision.