]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/main.cxx
set /sim/fg-current to current working directory; getcwd() is defined in
[flightgear.git] / src / Main / main.cxx
index ce6a79aed47f60bb488419d5cc74b83930b17cb9..ffb8d499bfb9a631e06135eb01c0b861b58d2635 100644 (file)
@@ -66,8 +66,6 @@
 #include <Sound/beacon.hxx>
 #include <Sound/morse.hxx>
 #include <FDM/flight.hxx>
-// #include <FDM/ADA.hxx>
-#include <ATC/ATCdisplay.hxx>
 #include <ATC/ATCmgr.hxx>
 #include <ATC/AIMgr.hxx>
 #include <Time/tmp.hxx>
@@ -156,6 +154,7 @@ void fgUpdateTimeDepCalcs() {
 
         if ( !inited ) {
             inited = true;
+            fgSetBool("/sim/signals/fdm-initialized", true);
         }
 
         if ( replay_state->getIntValue() == 0 ) {
@@ -322,7 +321,6 @@ static void fgMainLoop( void ) {
     }
     last_time_stamp = current_time_stamp;
     globals->inc_sim_time_sec( delta_time_sec );
-    SGAnimation::set_sim_time_sec( globals->get_sim_time_sec() );
 
     // These are useful, especially for Nasal scripts.
     fgSetDouble("/sim/time/delta-realtime-sec", real_delta_time_sec);
@@ -513,29 +511,8 @@ static void fgMainLoop( void ) {
     //
     double visibility_meters = fgGetDouble("/environment/visibility-m");
     FGViewer *current_view = globals->get_current_view();
-    // Let the scenery center follow the current view position with
-    // 30m increments.
-    //
-    // Having the scenery center near the view position will eliminate
-    // jitter of objects which are placed very near the view position
-    // and haveing it's center near that view position.
-    // So the 3d insruments of the aircraft will not jitter with this.
-    // 
-    // Following the view position exactly would introduce jitter of
-    // the scenery tiles (they would be from their center up to 10000m
-    // to the view and this will introduce roundoff too). By stepping
-    // at 30m incements the roundoff error of the scenery tiles is
-    // still present, but we will make exactly the same roundoff error
-    // at each frame until the center is switched to a new
-    // position. This roundoff is still visible but you will most
-    // propably not notice.
-    double *vp = globals->get_current_view()->get_absolute_view_pos();
-    SGVec3d cntr(vp);
-    if (30.0*30.0 < distSqr(cntr, globals->get_scenery()->get_center()))
-      globals->get_scenery()->set_center( cntr );
-
-    globals->get_tile_mgr()->prep_ssg_nodes( current_view->getSGLocation(),
-                                             visibility_meters );
+
+    globals->get_tile_mgr()->prep_ssg_nodes( visibility_meters );
     // update tile manager for view...
     SGLocation *view_location = globals->get_current_view()->getSGLocation();
     globals->get_tile_mgr()->update( view_location, visibility_meters );
@@ -548,8 +525,7 @@ static void fgMainLoop( void ) {
         double ref_time, r;
         SGVec3d pt;
         bool valid = cur_fdm_state->is_valid_m(&ref_time, pt.sg(), &r);
-        double *vp = globals->get_current_view()->get_absolute_view_pos();
-        SGVec3d viewpos(vp);
+        SGVec3d viewpos(globals->get_current_view()->get_view_pos());
         if (valid && distSqr(viewpos, pt) < r*r) {
             // Reuse the cache ...
             double lev
@@ -613,14 +589,6 @@ static void fgMainLoop( void ) {
         globals->get_soundmgr()->set_volume(init_volume);
     }
 
-    if (fgGetBool("/sim/rendering/specular-highlight")) {
-        glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
-       // glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
-    } else {
-        glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
-        // glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
-    }
-
     fgRequestRedraw();
 
     SG_LOG( SG_ALL, SG_DEBUG, "" );
@@ -635,18 +603,12 @@ static void fgMainLoop( void ) {
 // then on.
 
 static void fgIdleFunction ( void ) {
+    // Some intialization requires a valid graphics context, in
+    // particular that of plib. Boo, hiss!
+    fgMakeCurrent();
     if ( idle_state == 0 ) {
         idle_state++;
 
-#ifdef GL_EXT_texture_lod_bias
-        // negative values sharpen, positive values blur mipmapped textures
-        glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, -0.5 ) ;
-#endif
-        fgSplashProgress("setting up scenegraph & user interface");
-
-
-    } else if ( idle_state == 1 ) {
-        idle_state++;
         // 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 our window. :-(
@@ -664,14 +626,12 @@ static void fgIdleFunction ( void ) {
         general.set_glDepthBits( tmp );
         SG_LOG ( SG_GENERAL, SG_INFO, "Depth buffer bits = " << tmp );
 
-        // Initialize ssg (from plib).  Needs to come before we do any
-        // other ssg stuff, but after opengl has been initialized.
-        ssgInit();
-
-        // Initialize the user interface (we need to do this before
-        // passing off control to the OS main loop and before
-        // fgInitGeneral to get our fonts !!!
+        // Initialize the user interface so that we can use fonts
         guiInit();
+
+
+    } else if ( idle_state == 1 ) {
+        idle_state++;
         fgSplashProgress("reading aircraft list");
 
 
@@ -681,21 +641,21 @@ static void fgIdleFunction ( void ) {
         fgReadAircraft();
 
         // get the address of our OpenGL extensions
-        if (SGIsOpenGLExtensionSupported("GL_EXT_point_parameters") ) {
-            glPointParameterIsSupported = true;
-            glPointParameterfPtr = (glPointParameterfProc)
-                SGLookupFunction("glPointParameterfEXT");
-            glPointParameterfvPtr = (glPointParameterfvProc)
-                SGLookupFunction("glPointParameterfvEXT");
-        } else if ( SGIsOpenGLExtensionSupported("GL_ARB_point_parameters") ) {
-            glPointParameterIsSupported = true;
-            glPointParameterfPtr = (glPointParameterfProc)
-                SGLookupFunction("glPointParameterfARB");
-            glPointParameterfvPtr = (glPointParameterfvProc)
-                SGLookupFunction("glPointParameterfvARB");
-        } else {
-            glPointParameterIsSupported = false;
-        }
+//         if (SGIsOpenGLExtensionSupported("GL_EXT_point_parameters") ) {
+//             glPointParameterIsSupported = true;
+//             glPointParameterfPtr = (glPointParameterfProc)
+//                 SGLookupFunction("glPointParameterfEXT");
+//             glPointParameterfvPtr = (glPointParameterfvProc)
+//                 SGLookupFunction("glPointParameterfvEXT");
+//         } else if ( SGIsOpenGLExtensionSupported("GL_ARB_point_parameters") ) {
+//             glPointParameterIsSupported = true;
+//             glPointParameterfPtr = (glPointParameterfProc)
+//                 SGLookupFunction("glPointParameterfARB");
+//             glPointParameterfvPtr = (glPointParameterfvProc)
+//                 SGLookupFunction("glPointParameterfvARB");
+//         } else {
+//             glPointParameterIsSupported = false;
+//         }
         fgSplashProgress("reading airport & navigation data");
 
 
@@ -710,6 +670,7 @@ static void fgIdleFunction ( void ) {
         // based on the requested presets, calculate the true starting
         // lon, lat
         fgInitPosition();
+        fgInitTowerLocationListener();
 
         SGTime *t = fgInitTime();
         globals->set_time_params( t );
@@ -837,7 +798,6 @@ static void fgIdleFunction ( void ) {
         // lighting->addKid( airport );
 
         // build our custom render states
-        globals->get_renderer()->build_states();
         fgSplashProgress("initializing subsystems");
 
 
@@ -975,7 +935,7 @@ bool fgMainInit( int argc, char **argv ) {
     fgInitFGRoot(argc, argv);
 
     // Check for the correct base package version
-    static char required_version[] = "0.9.10";
+    static char required_version[] = "0.9.11";
     string base_version = fgBasePackageVersion();
     if ( !(base_version == required_version) ) {
         // tell the operator how to use this application
@@ -992,8 +952,6 @@ bool fgMainInit( int argc, char **argv ) {
         exit(-1);
     }
 
-    sgUseDisplayList = fgGetBool( "/sim/rendering/use-display-list", true );
-
     // Load the configuration parameters.  (Command line options
     // override config file options.  Config file options override
     // defaults.)
@@ -1035,7 +993,7 @@ bool fgMainInit( int argc, char **argv ) {
 
     // Initialize the splash screen right away
     fntInit();
-    fgSplashInit(fgGetString("/sim/startup/splash-texture"));
+    fgSplashInit();
 
     // pass control off to the master event handler
     fgOSMainLoop();