]> git.mxchange.org Git - flightgear.git/commitdiff
Patches from Norm Vine to improve framerate and add a new
authordavid <david>
Sun, 7 Apr 2002 15:24:32 +0000 (15:24 +0000)
committerdavid <david>
Sun, 7 Apr 2002 15:24:32 +0000 (15:24 +0000)
#ifdef'ed-out mode for syncing fullscreen with user settings in
Windows.

src/GUI/apt_dlg.cxx
src/GUI/gui_local.cxx
src/Main/fg_commands.cxx
src/Main/fg_init.cxx
src/Main/main.cxx
src/Network/atc610x.cxx
src/Network/net_fdm.hxx
src/Scenery/tileentry.cxx
src/Scenery/tileentry.hxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx

index 41d2e21c572a0114ec549acc1f9aec40ae753e54..4d45d829171f08166defe7bfde9edd5d73a9e0fd 100644 (file)
@@ -100,8 +100,10 @@ void AptDialog_OK (puObject *)
                                          SGD_RADIANS_TO_DEGREES);
             // BusyCursor(0);
             fgReInitSubsystems();
+           double visibility_meters =
+             fgGetDouble("/environment/visibility-m");
             global_tile_mgr.update( longitude->getDoubleValue(),
-                                    latitude->getDoubleValue() );
+                                    latitude->getDoubleValue(),visibility_meters );
             // BusyCursor(1);
         } else {
             AptId  += " not in database.";
index f537d60890d6e37b582a75d3510387501c6828ac..df6ac67e1272c653af7eb4c735dca0400a491ec5 100644 (file)
@@ -88,8 +88,9 @@ void reInit(puObject *cb)
     fgReInitSubsystems();
 
     // reduntant(fgReInitSubsystems) ?
+    double visibility_meters = fgGetDouble("/environment/visibility-m");
     global_tile_mgr.update( fgGetDouble("/position/longitude-deg"),
-                            fgGetDouble("/position/latitude-deg") );
+                            fgGetDouble("/position/latitude-deg"),visibility_meters );
     
     cur_light_params.Update();
 
index d8677b50febaf2526cca367e1e9bb3bb93fa2f7d..09e0d029d2f9c6e414f8bd47470965f019af649b 100644 (file)
@@ -307,8 +307,10 @@ do_tile_cache_reload (const SGPropertyNode * arg, SGCommandState ** state)
     // BusyCursor(0);
     if ( global_tile_mgr.init() ) {
        // Load the local scenery data
+        double visibility_meters = fgGetDouble("/environment/visibility-m");
        global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
-                              fgGetDouble("/position/latitude-deg"));
+                              fgGetDouble("/position/latitude-deg"),
+                              visibility_meters);
     } else {
        SG_LOG( SG_GENERAL, SG_ALERT, 
                "Error in Tile Manager initialization!" );
index 14b5376396a9323f295f56b85aa8b57e159bda53..deace45193936baf5207bf35b0fcd4597b3b57ff 100644 (file)
@@ -712,8 +712,11 @@ bool fgInitSubsystems( void ) {
 
     if ( global_tile_mgr.init() ) {
        // Load the local scenery data
+       double visibility_meters = fgGetDouble("/environment/visibility-m");
+               
        global_tile_mgr.update( longitude->getDoubleValue(),
-                               latitude->getDoubleValue() );
+                               latitude->getDoubleValue(),
+                               visibility_meters );
     } else {
        SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
        exit(-1);
index e83f4b70605242e6c0e4efa1243c6097a78ddcd1..ef3071dc862306b9a2620e8979367660f85908dd 100644 (file)
@@ -419,6 +419,8 @@ void fgRenderFrame( void ) {
     // Update the default (kludged) properties.
     fgUpdateProps();
 
+    FGViewer *current__view = globals->get_current_view();
+
     fgLIGHT *l = &cur_light_params;
     static double last_visibility = -9999;
 
@@ -492,13 +494,14 @@ void fgRenderFrame( void ) {
        // ssg does to set up the model view matrix
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
-       ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
+       ssgSetCamera( (sgVec4 *)current__view->get_VIEW() );
 
        // set the opengl state to known default values
        default_state->force();
 
        // update fog params if visibility has changed
-       thesky->set_visibility(fgGetDouble("/environment/visibility-m"));
+       double visibility_meters = fgGetDouble("/environment/visibility-m");
+       thesky->set_visibility(visibility_meters);
 
        thesky->modify_vis( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER,
                            ( global_multi_loop * fgGetInt("/sim/speed-up") )
@@ -544,9 +547,9 @@ void fgRenderFrame( void ) {
                 << " moon ra = " << globals->get_ephem()->getMoonRightAscension()
                 << " moon dec = " << globals->get_ephem()->getMoonDeclination() << endl; */
 
-           thesky->reposition( globals->get_current_view()->get_view_pos(),
-                               globals->get_current_view()->get_zero_elev(),
-                               globals->get_current_view()->get_world_up(),
+           thesky->reposition( current__view->get_view_pos(),
+                               current__view->get_zero_elev(),
+                               current__view->get_world_up(),
                                longitude->getDoubleValue()
                                  * SGD_DEGREES_TO_RADIANS,
                                latitude->getDoubleValue()
@@ -591,8 +594,8 @@ void fgRenderFrame( void ) {
 
        // glMatrixMode( GL_PROJECTION );
        // glLoadIdentity();
-       ssgSetFOV( globals->get_current_view()->get_h_fov(),
-                  globals->get_current_view()->get_v_fov() );
+       ssgSetFOV( current__view->get_h_fov(),
+                  current__view->get_v_fov() );
 
        double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
            - scenery.get_cur_elev();
@@ -614,7 +617,8 @@ void fgRenderFrame( void ) {
        current_model.update(dt_ms);
 
        // $$$ begin - added VS Renganthan 17 Oct 2K
-       fgUpdateDCS();
+       if(objc)
+         fgUpdateDCS();
        // $$$ end - added VS Renganthan 17 Oct 2K
 
 # ifdef FG_NETWORK_OLK
@@ -639,7 +643,7 @@ void fgRenderFrame( void ) {
 # endif
 
        // position tile nodes and update range selectors
-       global_tile_mgr.prep_ssg_nodes();
+       global_tile_mgr.prep_ssg_nodes(visibility_meters);
 
        if ( fgGetBool("/sim/rendering/skyblend") ) {
            // draw the sky backdrop
@@ -724,7 +728,7 @@ void fgRenderFrame( void ) {
        }
 
         // if in cockpit view adjust nearfar...
-        if (globals->get_current_view()->getType() == 0 ) {
+        if (current__view->getType() == 0 ) {
           glClearDepth(1);
           glClear(GL_DEPTH_BUFFER_BIT);
           ssgSetNearFar( cockpit_nearplane, cockpit_farplane );
@@ -1088,8 +1092,9 @@ static void fgMainLoop( void ) {
 #endif
 
     // see if we need to load any new scenery tiles
+    double visibility_meters = fgGetDouble("/environment/visibility-m");
     global_tile_mgr.update( longitude->getDoubleValue(),
-                           latitude->getDoubleValue() );
+                           latitude->getDoubleValue(), visibility_meters );
 
     // see if we need to load any deferred-load textures
     material_lib.load_next_deferred();
@@ -1216,7 +1221,7 @@ static void fgIdleFunction ( void ) {
        // We've finished all our initialization steps, from now on we
        // run the main loop.
 
-       fgMainLoop();
+       glutIdleFunc(fgMainLoop);
     } else {
        if ( fgGetBool("/sim/startup/splash-screen") ) {
            fgSplashUpdate(0.0);
@@ -1238,9 +1243,10 @@ void fgReshape( int width, int height ) {
     }
 
     // for all views
-    for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
-       globals->get_viewmgr()->get_view(i)->
-            set_aspect_ratio((float)view_h / (float)width);
+    FGViewMgr *viewmgr = globals->get_viewmgr();
+    for ( int i = 0; i < viewmgr->size(); ++i ) {
+      viewmgr->get_view(i)->
+       set_aspect_ratio((float)view_h / (float)width);
     }
 
     glViewport( 0, (GLint)(height - view_h), (GLint)(width), (GLint)(view_h) );
@@ -1249,13 +1255,12 @@ void fgReshape( int width, int height ) {
     fgSetInt("/sim/startup/ysize", height);
     guiInitMouse(width, height);
 
-    ssgSetFOV( globals->get_current_view()->get_h_fov(),
-              globals->get_current_view()->get_v_fov() );
+    ssgSetFOV( viewmgr->get_current_view()->get_h_fov(),
+              viewmgr->get_current_view()->get_v_fov() );
 
     fgHUDReshape();
 }
 
-
 // Initialize GLUT and define a main window
 int fgGlutInit( int *argc, char **argv ) {
 
@@ -1284,16 +1289,38 @@ int fgGlutInit( int *argc, char **argv ) {
     } else {
        // Open the cool new 'game mode' window
        char game_mode_str[256];
+//#define SYNC_OPENGL_WITH_DESKTOP_SETTINGS
+#if defined(WIN32) && defined(SYNC_OPENGL_WITH_DESKTOP_SETTINGS)
+#ifndef ENUM_CURRENT_SETTINGS
+#define ENUM_CURRENT_SETTINGS       ((DWORD)-1)
+#define ENUM_REGISTRY_SETTINGS      ((DWORD)-2)
+#endif
+
+       DEVMODE dm;
+       dm.dmSize = sizeof(DEVMODE);
+       EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
+       fgSetInt("/sim/startup/xsize", dm.dmPelsWidth);
+       fgSetInt("/sim/startup/ysize", dm.dmPelsHeight);
+       glutInitWindowSize( fgGetInt("/sim/startup/xsize"),
+                                               fgGetInt("/sim/startup/ysize") );
+       sprintf( game_mode_str, "%dx%d:%d@%d",
+                        dm.dmPelsWidth,
+                        dm.dmPelsHeight,
+                        dm.dmBitsPerPel,
+                        dm.dmDisplayFrequency );
+#else
+       // Open the cool new 'game mode' window
        sprintf( game_mode_str, "width=%d height=%d bpp=%d",
                 fgGetInt("/sim/startup/xsize"),
                 fgGetInt("/sim/startup/ysize"),
                 fgGetInt("/sim/rendering/bits-per-pixel"));
 
+#endif // HAVE_WINDOWS_H
        SG_LOG( SG_GENERAL, SG_INFO, 
                "game mode params = " << game_mode_str );
        glutGameModeString( game_mode_str );
        glutEnterGameMode();
-#endif
+#endif // GLUT_WRONG_VERSION
     }
 
     // This seems to be the absolute earliest in the init sequence
index a0e0c808e5bbcc282d56f052a820993651d48fd8..ae0c3bcee1c256f84763e88ff61a77cd2322cb78 100644 (file)
@@ -32,7 +32,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdio.h>              //snprintf
-#if defined( _MSC_VER )
+#if defined( _MSC_VER ) || defined(__MINGW32__)
 #  include <io.h>                 //lseek, read, write
 #endif
 
@@ -52,7 +52,7 @@
 
 SG_USING_STD(string);
 
-#if defined( _MSC_VER )
+#if defined( _MSC_VER ) || defined(__MINGW32__)
 #  define snprintf _snprintf
 #endif
 
index ad7bbda06e3be12f8a7e169e7f238e620fa39119..cb1aacbae68806729b34fe670575b1a37b5c2412 100644 (file)
@@ -30,6 +30,8 @@
 # error This library requires C++
 #endif                                   
 
+#include <time.h> // time_t
+
 const int FG_NET_FDM_VERSION = 5;
 
 // Define a structure containing the top level flight dynamics model
index 3d3b8c6caa1e3690909fa425ee36e63917023a33..75203de9d34b43fa4d791ff93047dfb93187ce66 100644 (file)
@@ -750,7 +750,7 @@ void FGTileEntry::free_tile() {
 
 // Update the ssg transform node for this tile so it can be
 // properly drawn relative to our (0,0,0) point
-void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
+void FGTileEntry::prep_ssg_node( const Point3D& p, sgVec3 up, float vis) {
     if ( !loaded ) return;
 
     SetOffset( p );
@@ -759,10 +759,14 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
 #ifdef USE_UP_AND_COMING_PLIB_FEATURE
     terra_range->setRange( 0, SG_ZERO );
     terra_range->setRange( 1, vis + bounding_radius );
+    if ( gnd_lights_range ) {
     gnd_lights_range->setRange( 0, SG_ZERO );
     gnd_lights_range->setRange( 1, vis * 1.5 + bounding_radius );
-    rwy_lights_range->setRange( 0, SG_ZERO );
-    rwy_lights_range->setRange( 1, vis * 1.5 + bounding_radius );
+    }
+    if ( rwy_lights_range ) {
+      rwy_lights_range->setRange( 0, SG_ZERO );
+      rwy_lights_range->setRange( 1, vis * 1.5 + bounding_radius );
+    }
 #else
     float ranges[2];
     ranges[0] = SG_ZERO;
@@ -786,8 +790,8 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
        // z-buffer fighting.  We do this based on our altitude and
        // the distance this tile is away from scenery center.
 
-       sgVec3 up;
-       sgCopyVec3( up, globals->get_current_view()->get_world_up() );
+//     sgVec3 up;
+//     sgCopyVec3( up, globals->get_current_view()->get_world_up() );
 
        double agl;
        if ( current_aircraft.fdm_state ) {
index e1fe1d35b020a0280c6b6e289f01f0588fb317f6..d29f761b01a25f28116f065b97677d480b8b0a1a 100644 (file)
@@ -224,7 +224,7 @@ public:
 
     // Update the ssg transform node for this tile so it can be
     // properly drawn relative to our (0,0,0) point
-    void prep_ssg_node( const Point3D& p, float vis);
+    void prep_ssg_node( const Point3D& p, sgVec3 up, float vis);
 
     /**
      * Load tile data from a file.
index 1ef594afc91eda53960aa7c30cea4b7a91aaa7f8..0847248d44c3d265c05b7e1d5c23766aeb09fbc1 100644 (file)
@@ -150,7 +150,7 @@ void FGTileMgr::sched_tile( const SGBucket& b ) {
 
 
 // schedule a needed buckets for loading
-void FGTileMgr::schedule_needed() {
+void FGTileMgr::schedule_needed( double vis) {
     // sanity check (unfortunately needed!)
     if ( longitude < -180.0 || longitude > 180.0 
          || latitude < -90.0 || latitude > 90.0 )
@@ -165,7 +165,7 @@ void FGTileMgr::schedule_needed() {
    SG_LOG( SG_TERRAIN, SG_INFO,
            "scheduling needed tiles for " << longitude << " " << latitude );
 
-   vis = fgGetDouble("/environment/visibility-m");
+//   vis = fgGetDouble("/environment/visibility-m");
 
     double tile_width = current_bucket.get_width_m();
     double tile_height = current_bucket.get_height_m();
@@ -227,7 +227,8 @@ void FGTileMgr::initialize_queue()
     // start with the center tile and work out in concentric
     // "rings"
 
-    schedule_needed();
+    double visibility_meters = fgGetDouble("/environment/visibility-m");
+    schedule_needed(visibility_meters);
 
     // do we really want to lose this? CLO
 #if 0
@@ -251,7 +252,7 @@ void FGTileMgr::initialize_queue()
 // given the current lon/lat (in degrees), fill in the array of local
 // chunks.  If the chunk isn't already in the cache, then read it from
 // disk.
-int FGTileMgr::update( double lon, double lat ) {
+int FGTileMgr::update( double lon, double lat, double visibility_meters ) {
     // SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
     //         << lon << " " << lat );
 
@@ -276,7 +277,7 @@ int FGTileMgr::update( double lon, double lat ) {
        if ( !(current_bucket == previous_bucket) ) {
            // We've moved to a new bucket, we need to schedule any
            // needed tiles for loading.
-           schedule_needed();
+           schedule_needed(visibility_meters);
        }
     } else if ( state == Start || state == Inited ) {
        SG_LOG( SG_TERRAIN, SG_INFO, "State == Start || Inited" );
@@ -360,7 +361,7 @@ int FGTileMgr::update( double lon, double lat ) {
        sgdSetVec3( tmp_abs_view_pos, tmp.x(), tmp.y(), tmp.z() );
 
        // cout << "abs_view_pos = " << tmp_abs_view_pos << endl;
-       prep_ssg_nodes();
+       prep_ssg_nodes(visibility_meters);
 
        double tmp_elev;
        if ( fgCurrentElev(tmp_abs_view_pos, sc, &hit_list,
@@ -431,10 +432,10 @@ int FGTileMgr::update( double lon, double lat ) {
 }
 
 
-void FGTileMgr::prep_ssg_nodes() {
-    float vis = 0.0;
+void FGTileMgr::prep_ssg_nodes(float vis) {
+//    float vis = 0.0;
 
-    vis = fgGetDouble("/environment/visibility-m");
+//    vis = fgGetDouble("/environment/visibility-m");
 
     // traverse the potentially viewable tile list and update range
     // selector and transform
@@ -442,10 +443,13 @@ void FGTileMgr::prep_ssg_nodes() {
     FGTileEntry *e;
     tile_cache.reset_traversal();
 
+    sgVec3 up;
+    sgCopyVec3( up, globals->get_current_view()->get_world_up() );
+       
     while ( ! tile_cache.at_end() ) {
         // cout << "processing a tile" << endl;
        if ( (e = tile_cache.get_current()) ) {
-           e->prep_ssg_node( scenery.get_center(), vis);
+           e->prep_ssg_node( scenery.get_center(), up, vis);
         } else {
            SG_LOG(SG_INPUT, SG_ALERT, "warning ... empty tile in cache");
         }
index ff5fe42ba3eb1bf8038e1c15f3d1447f33350cfd..c1955f7db428ceb745919510d2a1535ea9b398ab 100644 (file)
@@ -78,7 +78,7 @@ private:
     void sched_tile( const SGBucket& b );
 
     // schedule a needed buckets for loading
-    void schedule_needed();
+    void schedule_needed(double visibility_meters);
 
     // see comment at prep_ssg_nodes()
     void prep_ssg_node( int idx );
@@ -162,7 +162,7 @@ public:
     // given the current lon/lat (in degrees), fill in the array of
     // local chunks.  If the chunk isn't already in the cache, then
     // read it from disk.
-    int update( double lon, double lat );
+    int update( double lon, double lat, double visibility_meters );
 
     // Determine scenery altitude.  Normally this just happens when we
     // render the scene, but we'd also like to be able to do this
@@ -178,7 +178,7 @@ public:
     // Prepare the ssg nodes ... for each tile, set it's proper
     // transform and update it's range selector based on current
     // visibilty
-    void prep_ssg_nodes();
+    void prep_ssg_nodes(float visibility_meters);
 };