]> git.mxchange.org Git - flightgear.git/blobdiff - Main/GLUTmain.c
Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
[flightgear.git] / Main / GLUTmain.c
index 4776739188f90e452f3454715564c91d5cf8f628..a5ac4bc61358c1337ac6f4dd1aa7372f27fddf01 100644 (file)
 
 #include <Main/GLUTkey.h>
 #include <Main/fg_init.h>
+#include <Main/fg_debug.h>
 #include <Main/views.h>
 
-#include <Include/constants.h>
+#include <Include/fg_constants.h>
 #include <Include/general.h>
 
 #include <Aircraft/aircraft.h>
 #include <Astro/moon.h>
+#include <Astro/planets.h>
 #include <Astro/sky.h>
 #include <Astro/stars.h>
 #include <Astro/sun.h>
@@ -49,7 +51,6 @@
 #include <Math/fg_geodesy.h>
 #include <Math/mat3.h>
 #include <Math/polar.h>
-#include <Scenery/mesh.h>
 #include <Scenery/scenery.h>
 #include <Scenery/tilemgr.h>
 #include <Time/event.h>
@@ -122,12 +123,12 @@ static void fgInitVisuals( void ) {
  **************************************************************************/
 
 static void fgUpdateViewParams( void ) {
-    struct fgFLIGHT *f;
+    fgFLIGHT *f;
     struct fgLIGHT *l;
     struct fgTIME *t;
     struct fgVIEW *v;
 
-    f = &current_aircraft.flight;
+    f = current_aircraft.flight;
     l = &cur_light_params;
     t = &cur_time_params;
     v = &current_view;
@@ -239,7 +240,7 @@ static void fgRenderFrame( void ) {
     /* update view volume parameters */
     fgUpdateViewParams();
 
-    xglClear( GL_DEPTH_BUFFER_BIT /* | GL_COLOR_BUFFER_BIT */ );
+    xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
 
     /* Tell GL we are switching to model view parameters */
     xglMatrixMode(GL_MODELVIEW);
@@ -257,13 +258,14 @@ static void fgRenderFrame( void ) {
     xglPushMatrix();
     /* Translate to view position */
     xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
-    /* Rotate based on gst (side real time) */
+    /* Rotate based on gst (sidereal time) */
     angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
     /* printf("Rotating astro objects by %.2f degrees\n",angle); */
     xglRotatef( angle, 0.0, 0.0, -1.0 );
 
     /* draw stars and planets */
     fgStarsRender();
+    fgPlanetsRender();
 
     /* draw the sun */
     fgSunRender();
@@ -274,7 +276,12 @@ static void fgRenderFrame( void ) {
     xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
     xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
     xglEnable( GL_CULL_FACE );
+    
+    /* Let's try some blending technique's (Durk)*/
+    glEnable(GL_BLEND);
+    glBlendFunc(GL_ONE, GL_ONE);
     fgMoonRender();
+    glDisable(GL_BLEND);
 
     xglPopMatrix();
 
@@ -310,12 +317,12 @@ static void fgRenderFrame( void ) {
  **************************************************************************/
 
 void fgUpdateTimeDepCalcs(int multi_loop) {
-    struct fgFLIGHT *f;
+    fgFLIGHT *f;
     struct fgTIME *t;
     struct fgVIEW *v;
     int i;
 
-    f = &current_aircraft.flight;
+    f = current_aircraft.flight;
     t = &cur_time_params;
     v = &current_view;
 
@@ -458,17 +465,17 @@ static void fgMainLoop( void ) {
     static int remainder = 0;
     int elapsed, multi_loop;
     double cur_elev;
-    double joy_x, joy_y;
-    int joy_b1, joy_b2;
-    struct fgAIRCRAFT *a;
-    struct fgFLIGHT *f;
+    /* double joy_x, joy_y; */
+    /* int joy_b1, joy_b2; */
+    fgAIRCRAFT *a;
+    fgFLIGHT *f;
     struct fgTIME *t;
 
-    printf("Running Main Loop\n");
-    printf("======= ==== ====\n");
+    fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
+    fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
 
     a = &current_aircraft;
-    f = &a->flight;
+    f = a->flight;
     t = &cur_time_params;
 
     /* update "time" */
@@ -483,15 +490,15 @@ static void fgMainLoop( void ) {
 
     /* Calculate model iterations needed */
     elapsed = fgGetTimeInterval();
-    printf("Time interval is = %d, previous remainder is = %d\n", elapsed
-          remainder);
-    printf("--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed);
+    fgPrintf( FG_ALL, FG_BULK, "Time interval is = %d, previous remainder is = %d\n"
+             elapsed, remainder);
+    fgPrintf( FG_ALL, FG_BULK, "--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed);
     elapsed += remainder;
 
     multi_loop = ((float)elapsed * 0.001) * DEFAULT_MODEL_HZ;
     remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
-    printf("Model iterations needed = %d, new remainder = %d\n", multi_loop
-          remainder);
+    fgPrintf( FG_ALL, FG_BULK, "Model iterations needed = %d, new remainder = %d\n"
+             multi_loop, remainder);
 
     /* Run flight model */
     if ( ! use_signals ) {
@@ -501,8 +508,12 @@ static void fgMainLoop( void ) {
 
     /* I'm just sticking this here for now, it should probably move 
      * eventually */
-    cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC, 
-                              FG_Latitude  * RAD_TO_ARCSEC);
+    /* cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC, 
+                              FG_Latitude  * RAD_TO_ARCSEC); */
+    /* there is no ground collision detection really, so for now I
+     * just hard code the ground elevation to be 0 */
+    cur_elev = 0;
+
     /* printf("Ground elevation is %.2f meters here.\n", cur_elev); */
     /* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
 
@@ -513,14 +524,14 @@ static void fgMainLoop( void ) {
 
        /* now set aircraft altitude above ground */
        FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
-       printf("<*> resetting altitude to %.0f meters\n", 
+       fgPrintf( FG_ALL, FG_BULK, "<*> resetting altitude to %.0f meters\n", 
               FG_Altitude * FEET_TO_METER);
     }
 
     fgAircraftOutputCurrent(a);
 
     /* see if we need to load any new scenery tiles */
-    /* fgTileMgrUpdate(); */
+    fgTileMgrUpdate();
 
     /* Process/manage pending events */
     fgEventProcess();
@@ -528,7 +539,7 @@ static void fgMainLoop( void ) {
     /* redraw display */
     fgRenderFrame();
 
-    printf("\n");
+    fgPrintf( FG_ALL, FG_DEBUG, "\n");
 }
 
 
@@ -560,9 +571,9 @@ static void fgReshape( int width, int height ) {
  **************************************************************************/
 
 int main( int argc, char *argv[] ) {
-    struct fgFLIGHT *f;
+    fgFLIGHT *f;
 
-    f = &current_aircraft.flight;
+    f = current_aircraft.flight;
 
     printf("Flight Gear:  Version %s\n\n", VERSION);
 
@@ -628,17 +639,44 @@ int main( int argc, char *argv[] ) {
 }
 
 
-#ifdef NO_PRINTF
-  #include <stdarg.h>
-  int printf (const char *format, ...) {}
+#ifdef __SUNPRO_CC
+    extern "C" {
+       void __eprintf( void ) {
+       }
+    }
 #endif
 
-
 /* $Log$
-/* Revision 1.50  1998/01/19 19:27:07  curt
-/* Merged in make system changes from Bob Kuehne <rpk@sgi.com>
-/* This should simplify things tremendously.
+/* Revision 1.57  1998/02/07 15:29:40  curt
+/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
 /*
+ * Revision 1.56  1998/02/03 23:20:23  curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC.  Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf().  Also incorporated HUD changes
+ * by Michele America.
+ *
+ * Revision 1.55  1998/02/02 20:53:58  curt
+ * Incorporated Durk's changes.
+ *
+ * Revision 1.54  1998/01/31 00:43:10  curt
+ * Added MetroWorks patches from Carmen Volpe.
+ *
+ * Revision 1.53  1998/01/27 18:35:54  curt
+ * Minor tweaks.
+ *
+ * Revision 1.52  1998/01/27 00:47:56  curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.51  1998/01/26 15:57:05  curt
+ * Tweaks for dynamic scenery development.
+ *
+ * Revision 1.50  1998/01/19 19:27:07  curt
+ * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+ * This should simplify things tremendously.
+ *
  * Revision 1.49  1998/01/19 18:40:31  curt
  * Tons of little changes to clean up the code and to remove fatal errors
  * when building with the c++ compiler.