]> git.mxchange.org Git - flightgear.git/commitdiff
Added an averaged global frame rate counter.
authorcurt <curt>
Wed, 6 May 1998 03:16:23 +0000 (03:16 +0000)
committercurt <curt>
Wed, 6 May 1998 03:16:23 +0000 (03:16 +0000)
Added an option to control tile radius.

Main/GLUTmain.cxx
Main/airports.cxx
Main/fg_init.cxx
Main/options.cxx
Main/options.hxx

index 637800d19191e430b449a9b47a349b89cd661fc0..a518a8dca5946f72d6050f1b92baf0c62f7c50b0 100644 (file)
@@ -505,22 +505,26 @@ void fgInitTimeDepCalcs( void ) {
 // 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 ) {
+    fgAIRCRAFT *a;
+    fgFLIGHT *f;
+    fgGENERAL *g;
+    fgTIME *t;
     static int remainder = 0;
     int elapsed, multi_loop;
     double cur_elev;
+    int i;
+    double accum;
     // double joy_x, joy_y;
     // int joy_b1, joy_b2;
-    fgAIRCRAFT *a;
-    fgFLIGHT *f;
-    fgTIME *t;
-
-    fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
-    fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
 
     a = &current_aircraft;
     f = a->flight;
+    g = &general;
     t = &cur_time_params;
 
+    fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
+    fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
+
     // update "time"
     fgTimeUpdate(f, t);
 
@@ -531,13 +535,25 @@ static void fgMainLoop( void ) {
     fgElevSet( -joy_y );
     fgAileronSet( joy_x ); */
 
-    // Calculate model iterations needed
+    // Get elapsed time for this past frame
     elapsed = fgGetTimeInterval();
     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);
+
+    // Calculate frame rate average
+    accum = 0.0;
+    for ( i = FG_FRAME_RATE_HISTORY - 2; i >= 0; i-- ) {
+       accum += g->frames[i];
+       g->frames[i+1] = g->frames[i];
+    }
+    g->frames[0] = 1000.0 / (float)elapsed;
+    accum += g->frames[0];
+    g->frame_rate = accum / (float)FG_FRAME_RATE_HISTORY;
+
+    // Calculate model iterations needed for next frame
+    fgPrintf( FG_ALL, FG_DEBUG, 
+             "--> Frame rate is = %.2f\n", g->frame_rate);
     elapsed += remainder;
 
     multi_loop = (int)(((float)elapsed * 0.001) * DEFAULT_MODEL_HZ);
@@ -609,14 +625,10 @@ static void fgReshape( int width, int height ) {
 
 
 // Initialize GLUT and define a main window
-int fgGlutInit( int argc, char **argv ) {
-    fgOPTIONS *o;
-
-    o = &current_options;
-
+int fgGlutInit( int *argc, char **argv ) {
     // GLUT will extract all glut specific options so later on we only
     // need wory about our own.
-    xglutInit(&argc, argv);
+    xglutInit(argc, argv);
 
     // Define Display Parameters
     xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
@@ -664,7 +676,7 @@ int main( int argc, char **argv ) {
     fgPrintf(FG_GENERAL, FG_INFO, "Flight Gear:  Version %s\n\n", VERSION);
 
     // Initialize the Window/Graphics environment.
-    if( !fgGlutInit(argc, argv) ) {
+    if( !fgGlutInit(&argc, argv) ) {
        fgPrintf( FG_GENERAL, FG_EXIT, "GLUT initialization failed ...\n" );
     }
 
@@ -725,6 +737,10 @@ extern "C" {
 
 
 // $Log$
+// Revision 1.11  1998/05/06 03:16:23  curt
+// Added an averaged global frame rate counter.
+// Added an option to control tile radius.
+//
 // Revision 1.10  1998/05/03 00:47:31  curt
 // Added an option to enable/disable full-screen mode.
 //
index e85fe2dcbd5dbc5bad70305249e69f9e2f6a9e64..d64da23ccc016790ed5f71230d04db40a371b185 100644 (file)
@@ -84,6 +84,8 @@ int fgAIRPORTS::load( char *file ) {
     }
 
     fgclose(f);
+
+    return(1);
 }
 
 
@@ -109,6 +111,10 @@ fgAIRPORTS::~fgAIRPORTS( void ) {
 
 
 // $Log$
+// Revision 1.3  1998/05/06 03:16:24  curt
+// Added an averaged global frame rate counter.
+// Added an option to control tile radius.
+//
 // Revision 1.2  1998/04/28 21:42:50  curt
 // Wrapped zlib calls up so we can conditionally comment out zlib support.
 //
index 228626579cb879cee8d4308e594cf009979c23a8..f670e5cf05d3599aa43fa1548fd48c73d5515818 100644 (file)
@@ -131,9 +131,9 @@ int fgInitPosition( void ) {
     // FG_Altitude = FG_Runway_altitude + 3.758099;
 
     // Test Position
-    // FG_Longitude = ( -110.5 ) * DEG_TO_RAD;
-    // FG_Latitude  = (  34.5 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = (2646 + 6000);
+    // FG_Longitude = (  8.5 ) * DEG_TO_RAD;
+    // FG_Latitude  = ( 47.5 ) * DEG_TO_RAD;
+    // FG_Runway_altitude = ( 6000 );
     // FG_Altitude = FG_Runway_altitude + 3.758099;
 
     if ( strlen(o->airport_id) ) {
@@ -154,7 +154,7 @@ int fgInitPosition( void ) {
            FG_Latitude  = ( a.latitude ) * DEG_TO_RAD;
            FG_Runway_altitude = ( a.elevation + 300 );
            FG_Altitude = FG_Runway_altitude + 3.758099;
-       }           
+       }
     }
     
     fgPrintf( FG_GENERAL, FG_INFO, 
@@ -381,6 +381,10 @@ int fgInitSubsystems( void ) {
 
 
 // $Log$
+// Revision 1.10  1998/05/06 03:16:24  curt
+// Added an averaged global frame rate counter.
+// Added an option to control tile radius.
+//
 // Revision 1.9  1998/05/03 00:47:31  curt
 // Added an option to enable/disable full-screen mode.
 //
index fa04dda89f4fca5ccf236fbec43fb983c2c7c1d8..1d6d725f63398c7d9d1629cfab58a1d481a3f7ac 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <math.h>            // rint()
 #include <stdio.h>
-#include <stdlib.h>          // atof()
+#include <stdlib.h>          // atof(), atoi()
 #include <string.h>
 
 #include <Debug/fg_debug.h>
@@ -58,6 +58,9 @@ fgOPTIONS::fgOPTIONS( void ) {
     textures = 1;
     wireframe = 0;
 
+    // Scenery options
+    tile_radius = 7;
+
     // Time options
     time_offset = 0;
 }
@@ -157,7 +160,24 @@ static int parse_time_offset(char *time_str) {
     printf("parse_time_offset(): %d\n", result);
 
     return( result );
+}
+
 
+// Parse an int out of a --foo-bar=n type option 
+static int parse_int(char *arg, int min, int max) {
+    int result;
+
+    // advance past the '='
+    while ( (arg[0] != '=') && (arg[0] != '\0') ) {
+       arg++;
+    }
+       
+    result = atoi(arg);
+
+    if ( result < min ) { result = min; }
+    if ( result > max ) { result = max; }
+
+    return(result);
 }
 
 
@@ -206,6 +226,8 @@ int fgOPTIONS::parse( int argc, char **argv ) {
            wireframe = 0;      
        } else if ( strcmp(argv[i], "--enable-wireframe") == 0 ) {
            wireframe = 1;      
+       } else if ( strncmp(argv[i], "--tile-radius=", 14) == 0 ) {
+           tile_radius = parse_int(argv[i], 3, 7);
        } else if ( strncmp(argv[i], "--time-offset=", 14) == 0 ) {
            time_offset = parse_time_offset(argv[i]);
        } else {
@@ -252,6 +274,10 @@ void fgOPTIONS::usage ( void ) {
     printf("\t--enable-wireframe:  enable wireframe drawing mode\n");
     printf("\n");
 
+    printf("Scenery Options:\n");
+    printf("\t--tile-radius=n:  specify tile radius, must be odd 3, 5, or 7\n");
+    printf("\n");
+
     printf("Time Options:\n");
     printf("\t--time-offset=[+-]hh:mm:ss:  offset local time by this amount\n");
 }
@@ -263,6 +289,10 @@ fgOPTIONS::~fgOPTIONS( void ) {
 
 
 // $Log$
+// Revision 1.7  1998/05/06 03:16:25  curt
+// Added an averaged global frame rate counter.
+// Added an option to control tile radius.
+//
 // Revision 1.6  1998/05/03 00:47:32  curt
 // Added an option to enable/disable full-screen mode.
 //
index 6e23ddf47d8f2e485680e111e36f6584b7d52f43..e455c17611c44d1d817a4fa87bee19dec84f8cda 100644 (file)
@@ -55,6 +55,12 @@ public:
     int textures;      // Textures enabled/disabled
     int wireframe;     // Wireframe mode enabled/disabled
 
+    // Scenery options
+    int tile_radius;   // Square radius of rendered tiles.  for instance
+                       // if tile_radius = 3 then a 3 x 3 grid of tiles will 
+                       // be drawn.  Increase this to see terrain that is 
+                       // further away.
+
     // Time options
     int time_offset;   // Offset true time by this many seconds
 
@@ -80,6 +86,10 @@ extern fgOPTIONS current_options;
 
 
 // $Log$
+// Revision 1.6  1998/05/06 03:16:26  curt
+// Added an averaged global frame rate counter.
+// Added an option to control tile radius.
+//
 // Revision 1.5  1998/05/03 00:47:32  curt
 // Added an option to enable/disable full-screen mode.
 //