Added an option to control tile radius.
// 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 = ¤t_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);
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);
// Initialize GLUT and define a main window
-int fgGlutInit( int argc, char **argv ) {
- fgOPTIONS *o;
-
- o = ¤t_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 );
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" );
}
// $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.
//
}
fgclose(f);
+
+ return(1);
}
// $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.
//
// 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) ) {
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,
// $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.
//
#include <math.h> // rint()
#include <stdio.h>
-#include <stdlib.h> // atof()
+#include <stdlib.h> // atof(), atoi()
#include <string.h>
#include <Debug/fg_debug.h>
textures = 1;
wireframe = 0;
+ // Scenery options
+ tile_radius = 7;
+
// Time options
time_offset = 0;
}
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);
}
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 {
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");
}
// $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.
//
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
// $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.
//