]> git.mxchange.org Git - flightgear.git/blobdiff - Main/GLUTmain.cxx
Renamed class fgFLIGHT to class FGState as per request by JSB.
[flightgear.git] / Main / GLUTmain.cxx
index f671e3328e516f0f3d373ea484b5df995e977f9c..6d46fce53e68fb636ecc5a4b2e29dd2716f52484 100644 (file)
@@ -228,7 +228,7 @@ static void fgUpdateInstrViewParams( void ) {
 
 // Update all Visuals (redraws anything graphics related)
 static void fgRenderFrame( void ) {
-    fgFLIGHT *f;
+    FGState *f;
     fgLIGHT *l;
     fgTIME *t;
     fgVIEW *v;
@@ -239,7 +239,7 @@ static void fgRenderFrame( void ) {
     GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 };
     GLbitfield clear_mask;
 
-    f = current_aircraft.flight;
+    f = current_aircraft.fdm_state;
     l = &cur_light_params;
     t = &cur_time_params;
     v = &current_view;
@@ -371,13 +371,13 @@ static void fgRenderFrame( void ) {
 
 // Update internal time dependent calculations (i.e. flight model)
 void fgUpdateTimeDepCalcs(int multi_loop) {
-    fgFLIGHT *f;
+    FGState *f;
     fgLIGHT *l;
     fgTIME *t;
     fgVIEW *v;
     int i;
 
-    f = current_aircraft.flight;
+    f = current_aircraft.fdm_state;
     l = &cur_light_params;
     t = &cur_time_params;
     v = &current_view;
@@ -392,9 +392,11 @@ void fgUpdateTimeDepCalcs(int multi_loop) {
        fgAPRun();
 
        // printf("updating flight model x %d\n", multi_loop);
-       fgFlightModelUpdate(current_options.get_flight_model(), f, multi_loop);
+       fgFlightModelUpdate( current_options.get_flight_model(), 
+                            cur_fdm_state, multi_loop );
     } else {
-       fgFlightModelUpdate(current_options.get_flight_model(), f, 0);
+       fgFlightModelUpdate( current_options.get_flight_model(), 
+                            cur_fdm_state, 0 );
     }
 
     // update the view angle
@@ -425,7 +427,7 @@ void fgUpdateTimeDepCalcs(int multi_loop) {
        }
     }
 
-    double tmp = -(l->sun_rotation + FG_PI) - (FG_Psi - v->view_offset);
+    double tmp = -(l->sun_rotation + FG_PI) - (f->get_Psi() - v->view_offset);
     while ( tmp < 0.0 ) {
        tmp += FG_2PI;
     }
@@ -454,7 +456,7 @@ static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
 // What should we do when we have nothing else to do?  Let's get ready
 // for the next move and update the display?
 static void fgMainLoop( void ) {
-    fgFLIGHT *f;
+    FGState *f;
     fgGENERAL *g;
     fgTIME *t;
     static int remainder = 0;
@@ -462,7 +464,7 @@ static void fgMainLoop( void ) {
     int i;
     double accum;
 
-    f = current_aircraft.flight;
+    f = current_aircraft.fdm_state;
     g = &general;
     t = &cur_time_params;
 
@@ -474,33 +476,34 @@ static void fgMainLoop( void ) {
     // Fix elevation.  I'm just sticking this here for now, it should
     // probably move eventually
 
-    /* printf("Before - ground = %.2f  runway = %.2f  alt = %.2f\n",
+    printf("Before - ground = %.2f  runway = %.2f  alt = %.2f\n",
           scenery.cur_elev,
-          FG_Runway_altitude * FEET_TO_METER,
-          FG_Altitude * FEET_TO_METER); */
+          f->get_Runway_altitude() * FEET_TO_METER,
+          f->get_Altitude() * FEET_TO_METER);
 
     if ( scenery.cur_elev > -9990 ) {
-       if ( FG_Altitude * FEET_TO_METER < 
+       if ( f->get_Altitude() * FEET_TO_METER < 
             (scenery.cur_elev + alt_adjust_m - 3.0) ) {
            // now set aircraft altitude above ground
            printf("Current Altitude = %.2f < %.2f forcing to %.2f\n", 
-                  FG_Altitude * FEET_TO_METER,
+                  f->get_Altitude() * FEET_TO_METER,
                   scenery.cur_elev + alt_adjust_m - 3.0,
                   scenery.cur_elev + alt_adjust_m );
-           fgFlightModelSetAltitude( current_options.get_flight_model(), f, 
+           fgFlightModelSetAltitude( current_options.get_flight_model(), 
+                                     cur_fdm_state, 
                                      scenery.cur_elev + alt_adjust_m );
 
-           FG_LOG( FG_ALL, FG_BULK
+           FG_LOG( FG_ALL, FG_DEBUG
                    "<*> resetting altitude to " 
-                   << FG_Altitude * FEET_TO_METER << " meters" );
+                   << f->get_Altitude() * FEET_TO_METER << " meters" );
        }
-       FG_Runway_altitude = scenery.cur_elev * METER_TO_FEET;
+       f->set_Runway_altitude( scenery.cur_elev * METER_TO_FEET );
     }
 
-    /* printf("Adjustment - ground = %.2f  runway = %.2f  alt = %.2f\n",
+    printf("Adjustment - ground = %.2f  runway = %.2f  alt = %.2f\n",
           scenery.cur_elev,
-          FG_Runway_altitude * FEET_TO_METER,
-          FG_Altitude * FEET_TO_METER); */
+          f->get_Runway_altitude() * FEET_TO_METER,
+          f->get_Altitude() * FEET_TO_METER);
 
     // update "time"
     fgTimeUpdate(f, t);
@@ -606,7 +609,7 @@ static void fgMainLoop( void ) {
            // Angle of Attack next... -x^3(e^x) is my best guess Just
            // need to calculate some reasonable scaling factor and
            // then clamp it on the positive aoa (neg adj) side
-           double aoa = FG_Gamma_vert_rad * 2.2;
+           double aoa = f->get_Gamma_vert_rad() * 2.2;
            double tmp = 3.0;
            double aoa_adj = pow(-aoa, tmp) * pow(M_E, aoa);
            if (aoa_adj < -0.8) aoa_adj = -0.8;
@@ -807,6 +810,7 @@ static void fgReshape( int width, int height ) {
 
     v->winWidth = width;
     v->winHeight = height;
+    v->update_fov = true;
 
     // Inform gl of our view window size (now handled elsewhere)
     // xglViewport(0, 0, (GLint)width, (GLint)height);
@@ -854,6 +858,51 @@ int fgGlutInit( int *argc, char **argv ) {
        glutEnterGameMode();
     }
 
+    // This seems to be the absolute earliest in the init sequence
+    // that these calls will return valid info.  Too bad it's after
+    // we've already created and sized out window. :-(
+    general.glVendor = (char *)glGetString ( GL_VENDOR );
+    general.glRenderer = (char *)glGetString ( GL_RENDERER );
+    general.glVersion = (char *)glGetString ( GL_VERSION );
+
+    FG_LOG ( FG_GENERAL, FG_INFO, general.glRenderer );
+
+#if 0
+    // try to determine if we should adjust the initial default
+    // display resolution.  The options class defaults (is
+    // initialized) to 640x480.
+    string renderer = general.glRenderer;
+
+    // currently we only know how to deal with Mesa/Glide/Voodoo cards
+    if ( renderer.find( "Glide" ) != string::npos ) {
+       FG_LOG( FG_GENERAL, FG_INFO, "Detected a Glide driver" );
+       if ( renderer.find( "FB/8" ) != string::npos ) {
+           // probably a voodoo-2
+           if ( renderer.find( "TMU/SLI" ) != string::npos ) {
+               // probably two SLI'd Voodoo-2's
+               current_options.set_xsize( 1024 );
+               current_options.set_ysize( 768 );
+               FG_LOG( FG_GENERAL, FG_INFO,
+                       "It looks like you have two sli'd voodoo-2's." << endl
+                       << "upgrading your win resolution to 1024 x 768" );
+               glutReshapeWindow(1024, 768);
+           } else {
+               // probably a single non-SLI'd Voodoo-2
+               current_options.set_xsize( 800 );
+               current_options.set_ysize( 600 );
+               FG_LOG( FG_GENERAL, FG_INFO,
+                       "It looks like you have a voodoo-2." << endl
+                       << "upgrading your win resolution to 800 x 600" );
+               glutReshapeWindow(800, 600);
+           }
+       } else if ( renderer.find( "FB/2" ) != string::npos ) {
+           // probably a voodoo-1, stick with the default
+       }
+    } else {
+       // we have no special knowledge of this card, stick with the default
+    }
+#endif
+
     return(1);
 }
 
@@ -885,9 +934,9 @@ int fgGlutInitEvents( void ) {
 
 // Main ...
 int main( int argc, char **argv ) {
-    fgFLIGHT *f;
+    FGState *f;
 
-    f = current_aircraft.flight;
+    f = current_aircraft.fdm_state;
 
 #ifdef HAVE_BC5PLUS
     _control87(MCW_EM, MCW_EM);  /* defined in float.h */
@@ -897,9 +946,14 @@ int main( int argc, char **argv ) {
     // fgInitDebug();
 
     // set default log levels
-    fglog().setLogLevels( FG_ALL, FG_INFO );
+    fglog().setLogLevels( FG_ALL, FG_DEBUG );
+
+    FG_LOG( FG_GENERAL, FG_INFO, "Flight Gear:  Version " << VERSION << endl );
+
+    string root;
 
-    FG_LOG( FG_GENERAL, FG_INFO, "Flight Gear:  Version" << VERSION << endl );
+    FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
+    FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
 
     // Attempt to locate and parse a config file
     // First check fg_root
@@ -960,6 +1014,21 @@ int main( int argc, char **argv ) {
 
 
 // $Log$
+// Revision 1.72  1998/12/05 15:54:18  curt
+// Renamed class fgFLIGHT to class FGState as per request by JSB.
+//
+// Revision 1.71  1998/12/05 14:19:51  curt
+// Looking into a problem with cur_view_params.abs_view_pos initialization.
+//
+// Revision 1.70  1998/12/03 01:17:14  curt
+// Converted fgFLIGHT to a class.
+//
+// Revision 1.69  1998/11/23 20:51:26  curt
+// Fiddling with when I can get info from the opengl driver.
+//
+// Revision 1.68  1998/11/20 01:02:35  curt
+// Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
+//
 // Revision 1.67  1998/11/16 13:59:58  curt
 // Added pow() macro bug work around.
 // Added support for starting FGFS at various resolutions.