Added a keyboard binding to dynamically adjust field of view.
Added a command line option to specify fov. Adjusted terrain color. Root path info moved to fgOPTIONS. Added ability to parse options out of a config file.
This commit is contained in:
parent
17cfc04cef
commit
c57071acfd
5 changed files with 299 additions and 91 deletions
|
@ -106,6 +106,9 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
case 87: /* W key */
|
case 87: /* W key */
|
||||||
displayInstruments = !displayInstruments;
|
displayInstruments = !displayInstruments;
|
||||||
return;
|
return;
|
||||||
|
case 88: /* X key */
|
||||||
|
o->fov *= 1.05;
|
||||||
|
return;
|
||||||
case 90: /* Z key */
|
case 90: /* Z key */
|
||||||
w->visibility /= 1.10;
|
w->visibility /= 1.10;
|
||||||
xglFogf (GL_FOG_START, w->visibility / 1000000.0 );
|
xglFogf (GL_FOG_START, w->visibility / 1000000.0 );
|
||||||
|
@ -168,6 +171,9 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
case 116: /* t key */
|
case 116: /* t key */
|
||||||
t->warp_delta += 30;
|
t->warp_delta += 30;
|
||||||
return;
|
return;
|
||||||
|
case 120: /* X key */
|
||||||
|
o->fov /= 1.05;
|
||||||
|
return;
|
||||||
case 122: /* z key */
|
case 122: /* z key */
|
||||||
w->visibility *= 1.10;
|
w->visibility *= 1.10;
|
||||||
xglFogf (GL_FOG_START, w->visibility / 1000000.0 );
|
xglFogf (GL_FOG_START, w->visibility / 1000000.0 );
|
||||||
|
@ -179,7 +185,8 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
// if( fg_DebugOutput ) {
|
// if( fg_DebugOutput ) {
|
||||||
// fclose( fg_DebugOutput );
|
// fclose( fg_DebugOutput );
|
||||||
// }
|
// }
|
||||||
exit(0);
|
fgPrintf( FG_INPUT, FG_EXIT,
|
||||||
|
"Program exiting normally at user request.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,12 +274,19 @@ void GLUTspecialkey(int k, int x, int y) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.7 1998/05/07 23:14:14 curt
|
/* Revision 1.8 1998/05/13 18:29:56 curt
|
||||||
/* Added "D" key binding to set autopilot heading.
|
/* Added a keyboard binding to dynamically adjust field of view.
|
||||||
/* Made frame rate calculation average out over last 10 frames.
|
/* Added a command line option to specify fov.
|
||||||
/* Borland C++ floating point exception workaround.
|
/* Adjusted terrain color.
|
||||||
/* Added a --tile-radius=n option.
|
/* Root path info moved to fgOPTIONS.
|
||||||
|
/* Added ability to parse options out of a config file.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.7 1998/05/07 23:14:14 curt
|
||||||
|
* Added "D" key binding to set autopilot heading.
|
||||||
|
* Made frame rate calculation average out over last 10 frames.
|
||||||
|
* Borland C++ floating point exception workaround.
|
||||||
|
* Added a --tile-radius=n option.
|
||||||
|
*
|
||||||
* Revision 1.6 1998/04/28 01:20:20 curt
|
* Revision 1.6 1998/04/28 01:20:20 curt
|
||||||
* Type-ified fgTIME and fgVIEW.
|
* Type-ified fgTIME and fgVIEW.
|
||||||
* Added a command line option to disable textures.
|
* Added a command line option to disable textures.
|
||||||
|
|
|
@ -225,10 +225,12 @@ static void fgInitVisuals( void ) {
|
||||||
static void fgUpdateViewParams( void ) {
|
static void fgUpdateViewParams( void ) {
|
||||||
fgFLIGHT *f;
|
fgFLIGHT *f;
|
||||||
fgLIGHT *l;
|
fgLIGHT *l;
|
||||||
|
fgOPTIONS *o;
|
||||||
fgVIEW *v;
|
fgVIEW *v;
|
||||||
|
|
||||||
f = current_aircraft.flight;
|
f = current_aircraft.flight;
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
|
o = ¤t_options;
|
||||||
v = ¤t_view;
|
v = ¤t_view;
|
||||||
|
|
||||||
fgViewUpdate(f, v, l);
|
fgViewUpdate(f, v, l);
|
||||||
|
@ -239,13 +241,13 @@ static void fgUpdateViewParams( void ) {
|
||||||
// Tell GL we are about to modify the projection parameters
|
// Tell GL we are about to modify the projection parameters
|
||||||
xglMatrixMode(GL_PROJECTION);
|
xglMatrixMode(GL_PROJECTION);
|
||||||
xglLoadIdentity();
|
xglLoadIdentity();
|
||||||
gluPerspective(65.0, 2.0/win_ratio, 1.0, 100000.0);
|
gluPerspective(o->fov, 2.0/win_ratio, 1.0, 100000.0);
|
||||||
} else {
|
} else {
|
||||||
xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
|
xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
|
||||||
// Tell GL we are about to modify the projection parameters
|
// Tell GL we are about to modify the projection parameters
|
||||||
xglMatrixMode(GL_PROJECTION);
|
xglMatrixMode(GL_PROJECTION);
|
||||||
xglLoadIdentity();
|
xglLoadIdentity();
|
||||||
gluPerspective(65.0, 1.0/win_ratio, 10.0, 100000.0);
|
gluPerspective(o->fov, 1.0/win_ratio, 10.0, 100000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
xglMatrixMode(GL_MODELVIEW);
|
xglMatrixMode(GL_MODELVIEW);
|
||||||
|
@ -332,8 +334,8 @@ static void fgRenderFrame( void ) {
|
||||||
double angle;
|
double angle;
|
||||||
GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
|
GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
|
||||||
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||||
GLfloat color[4] = { 0.54, 0.44, 0.29, 1.0 };
|
GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 };
|
||||||
|
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
o = ¤t_options;
|
o = ¤t_options;
|
||||||
t = &cur_time_params;
|
t = &cur_time_params;
|
||||||
|
@ -425,8 +427,8 @@ static void fgRenderFrame( void ) {
|
||||||
xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
|
xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
|
||||||
} else {
|
} else {
|
||||||
xglDisable( GL_TEXTURE_2D );
|
xglDisable( GL_TEXTURE_2D );
|
||||||
xglMaterialfv (GL_FRONT, GL_AMBIENT, color);
|
xglMaterialfv (GL_FRONT, GL_AMBIENT, terrain_color);
|
||||||
xglMaterialfv (GL_FRONT, GL_DIFFUSE, color);
|
xglMaterialfv (GL_FRONT, GL_DIFFUSE, terrain_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
fgTileMgrRender();
|
fgTileMgrRender();
|
||||||
|
@ -675,9 +677,12 @@ int fgGlutInitEvents( void ) {
|
||||||
// Main ...
|
// Main ...
|
||||||
int main( int argc, char **argv ) {
|
int main( int argc, char **argv ) {
|
||||||
fgFLIGHT *f;
|
fgFLIGHT *f;
|
||||||
|
fgOPTIONS *o;
|
||||||
|
char config[256];
|
||||||
int result; // Used in command line argument.
|
int result; // Used in command line argument.
|
||||||
|
|
||||||
f = current_aircraft.flight;
|
f = current_aircraft.flight;
|
||||||
|
o = ¤t_options;
|
||||||
|
|
||||||
#ifdef HAVE_BC5PLUS
|
#ifdef HAVE_BC5PLUS
|
||||||
_control87(MCW_EM, MCW_EM); /* defined in float.h */
|
_control87(MCW_EM, MCW_EM); /* defined in float.h */
|
||||||
|
@ -693,14 +698,27 @@ int main( int argc, char **argv ) {
|
||||||
fgPrintf( FG_GENERAL, FG_EXIT, "GLUT initialization failed ...\n" );
|
fgPrintf( FG_GENERAL, FG_EXIT, "GLUT initialization failed ...\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse remaining command line options
|
// Attempt to locate and parse a config file
|
||||||
result = current_options.parse(argc, argv);
|
// First check fg_root
|
||||||
|
strcpy(config, o->fg_root);
|
||||||
|
strcat(config, "/system.fgfsrc");
|
||||||
|
result = o->parse_config_file(config);
|
||||||
|
|
||||||
|
// Next check home directory
|
||||||
|
if ( getenv("HOME") != NULL ) {
|
||||||
|
strcpy(config, getenv("HOME"));
|
||||||
|
strcat(config, "/.fgfsrc");
|
||||||
|
result = o->parse_config_file(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse remaining command line options
|
||||||
|
// These will override anything specified in a config file
|
||||||
|
result = o->parse_command_line(argc, argv);
|
||||||
if ( result != FG_OPTIONS_OK ) {
|
if ( result != FG_OPTIONS_OK ) {
|
||||||
// Something must have gone horribly wrong with the command
|
// Something must have gone horribly wrong with the command
|
||||||
// line parsing or maybe the user just requested help ... :-)
|
// line parsing or maybe the user just requested help ... :-)
|
||||||
current_options.usage();
|
o->usage();
|
||||||
fgPrintf( FG_GENERAL, FG_EXIT, "\nShutting down ...\n");
|
fgPrintf( FG_GENERAL, FG_EXIT, "\nExiting ...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are a few miscellaneous things that aren't really
|
// These are a few miscellaneous things that aren't really
|
||||||
|
@ -750,6 +768,13 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.14 1998/05/13 18:29:57 curt
|
||||||
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
|
// Added a command line option to specify fov.
|
||||||
|
// Adjusted terrain color.
|
||||||
|
// Root path info moved to fgOPTIONS.
|
||||||
|
// Added ability to parse options out of a config file.
|
||||||
|
//
|
||||||
// Revision 1.13 1998/05/11 18:18:15 curt
|
// Revision 1.13 1998/05/11 18:18:15 curt
|
||||||
// For flat shading use "glHint (GL_FOG_HINT, GL_FASTEST )"
|
// For flat shading use "glHint (GL_FOG_HINT, GL_FASTEST )"
|
||||||
//
|
//
|
||||||
|
|
|
@ -169,26 +169,23 @@ int fgInitPosition( void ) {
|
||||||
// General house keeping initializations
|
// General house keeping initializations
|
||||||
int fgInitGeneral( void ) {
|
int fgInitGeneral( void ) {
|
||||||
fgGENERAL *g;
|
fgGENERAL *g;
|
||||||
|
fgOPTIONS *o;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g = &general;
|
g = &general;
|
||||||
|
o = ¤t_options;
|
||||||
|
|
||||||
fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" );
|
fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" );
|
||||||
fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" );
|
fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" );
|
||||||
|
|
||||||
// determine the fg root path.
|
if ( !strlen(o->fg_root) ) {
|
||||||
if( !(g->root_dir) ) {
|
// No root path set? Then assume, we will exit if this is
|
||||||
// If not set by command line test for environmental var..
|
// wrong when looking for support files.
|
||||||
g->root_dir = getenv("FG_ROOT");
|
fgPrintf( FG_GENERAL, FG_EXIT, "%s %s\n",
|
||||||
if ( !g->root_dir ) {
|
"Cannot continue without environment variable FG_ROOT",
|
||||||
// No root path set? Then assume, we will exit if this is
|
"being defined.");
|
||||||
// wrong when looking for support files.
|
|
||||||
fgPrintf( FG_GENERAL, FG_EXIT, "%s %s\n",
|
|
||||||
"Cannot continue without environment variable FG_ROOT",
|
|
||||||
"being defined.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", g->root_dir);
|
fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", o->fg_root);
|
||||||
|
|
||||||
// prime the frame rate counter pump
|
// prime the frame rate counter pump
|
||||||
for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) {
|
for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) {
|
||||||
|
@ -387,6 +384,13 @@ int fgInitSubsystems( void ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.12 1998/05/13 18:29:58 curt
|
||||||
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
|
// Added a command line option to specify fov.
|
||||||
|
// Adjusted terrain color.
|
||||||
|
// Root path info moved to fgOPTIONS.
|
||||||
|
// Added ability to parse options out of a config file.
|
||||||
|
//
|
||||||
// Revision 1.11 1998/05/07 23:14:15 curt
|
// Revision 1.11 1998/05/07 23:14:15 curt
|
||||||
// Added "D" key binding to set autopilot heading.
|
// Added "D" key binding to set autopilot heading.
|
||||||
// Made frame rate calculation average out over last 10 frames.
|
// Made frame rate calculation average out over last 10 frames.
|
||||||
|
|
273
Main/options.cxx
273
Main/options.cxx
|
@ -33,6 +33,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Debug/fg_debug.h>
|
#include <Debug/fg_debug.h>
|
||||||
|
#include <Include/fg_zlib.h>
|
||||||
|
|
||||||
#include "options.hxx"
|
#include "options.hxx"
|
||||||
|
|
||||||
|
@ -45,6 +46,24 @@ fgOPTIONS current_options;
|
||||||
fgOPTIONS::fgOPTIONS( void ) {
|
fgOPTIONS::fgOPTIONS( void ) {
|
||||||
// set initial values/defaults
|
// set initial values/defaults
|
||||||
|
|
||||||
|
if ( getenv("FG_ROOT") != NULL ) {
|
||||||
|
// fg_root could be anywhere, so default to environmental
|
||||||
|
// variable $FG_ROOT if it is set.
|
||||||
|
|
||||||
|
strcpy(fg_root, getenv("FG_ROOT"));
|
||||||
|
} else {
|
||||||
|
// Otherwise, default to a random compiled in location if
|
||||||
|
// $FG_ROOT is not set. This can still be overridden from the
|
||||||
|
// command line or a config file.
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
strcpy(fg_root, "\\FlightGear");
|
||||||
|
#else
|
||||||
|
strcpy(fg_root, "/usr/local/lib/FlightGear");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// default airport id
|
||||||
strcpy(airport_id, "");
|
strcpy(airport_id, "");
|
||||||
|
|
||||||
// Features
|
// Features
|
||||||
|
@ -52,6 +71,7 @@ fgOPTIONS::fgOPTIONS( void ) {
|
||||||
|
|
||||||
// Rendering options
|
// Rendering options
|
||||||
fog = 1;
|
fog = 1;
|
||||||
|
fov = 65.0;
|
||||||
fullscreen = 0;
|
fullscreen = 0;
|
||||||
shading = 1;
|
shading = 1;
|
||||||
skyblend = 1;
|
skyblend = 1;
|
||||||
|
@ -66,6 +86,52 @@ fgOPTIONS::fgOPTIONS( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parse an int out of a --foo-bar=n type option
|
||||||
|
static int parse_int(char *arg) {
|
||||||
|
int result;
|
||||||
|
|
||||||
|
// advance past the '='
|
||||||
|
while ( (arg[0] != '=') && (arg[0] != '\0') ) {
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( arg[0] == '=' ) {
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("parse_int(): arg = %s\n", arg);
|
||||||
|
|
||||||
|
result = atoi(arg);
|
||||||
|
|
||||||
|
printf("parse_int(): result = %d\n", result);
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parse an int out of a --foo-bar=n type option
|
||||||
|
static double parse_double(char *arg) {
|
||||||
|
double result;
|
||||||
|
|
||||||
|
// advance past the '='
|
||||||
|
while ( (arg[0] != '=') && (arg[0] != '\0') ) {
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( arg[0] == '=' ) {
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("parse_double(): arg = %s\n", arg);
|
||||||
|
|
||||||
|
result = atof(arg);
|
||||||
|
|
||||||
|
printf("parse_double(): result = %.4f\n", result);
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// parse time string in the form of [+-]hh:mm:ss, returns the value in seconds
|
// parse time string in the form of [+-]hh:mm:ss, returns the value in seconds
|
||||||
static double parse_time(char *time_str) {
|
static double parse_time(char *time_str) {
|
||||||
char num[256];
|
char num[256];
|
||||||
|
@ -163,82 +229,118 @@ static int parse_time_offset(char *time_str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Parse an int out of a --foo-bar=n type option
|
// Parse --tile-radius=n type option
|
||||||
static int parse_int(char *arg, int min, int max) {
|
|
||||||
int result;
|
|
||||||
|
|
||||||
// advance past the '='
|
#define FG_RADIUS_MIN 3
|
||||||
while ( (arg[0] != '=') && (arg[0] != '\0') ) {
|
#define FG_RADIUS_MAX 9
|
||||||
arg++;
|
|
||||||
|
static int parse_tile_radius(char *arg) {
|
||||||
|
int radius, tmp;
|
||||||
|
|
||||||
|
radius = parse_int(arg);
|
||||||
|
|
||||||
|
// radius must be odd
|
||||||
|
tmp = radius / 2;
|
||||||
|
if ( radius == ( tmp * 2 ) ) {
|
||||||
|
radius -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( arg[0] == '=' ) {
|
if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
|
||||||
arg++;
|
if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
|
||||||
|
|
||||||
|
printf("parse_tile_radius(): radius = %d\n", radius);
|
||||||
|
|
||||||
|
return(radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parse --fov=x.xx type option
|
||||||
|
|
||||||
|
#define FG_FOV_MIN 0.1
|
||||||
|
#define FG_FOV_MAX 179.9
|
||||||
|
|
||||||
|
static double parse_fov(char *arg) {
|
||||||
|
double fov;
|
||||||
|
|
||||||
|
fov = parse_double(arg);
|
||||||
|
|
||||||
|
if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
|
||||||
|
if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
|
||||||
|
|
||||||
|
printf("parse_fov(): result = %.4f\n", fov);
|
||||||
|
|
||||||
|
return(fov);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parse a single option
|
||||||
|
int fgOPTIONS::parse_option( char *arg ) {
|
||||||
|
// General Options
|
||||||
|
if ( (strcmp(arg, "--help") == 0) ||
|
||||||
|
(strcmp(arg, "-h") == 0) ) {
|
||||||
|
// help/usage request
|
||||||
|
return(FG_OPTIONS_HELP);
|
||||||
|
} else if ( strcmp(arg, "--disable-hud") == 0 ) {
|
||||||
|
hud_status = 0;
|
||||||
|
} else if ( strcmp(arg, "--enable-hud") == 0 ) {
|
||||||
|
hud_status = 1;
|
||||||
|
} else if ( strncmp(arg, "--airport-id=", 13) == 0 ) {
|
||||||
|
arg += 13;
|
||||||
|
strncpy(airport_id, arg, 4);
|
||||||
|
} else if ( strncmp(arg, "--fg-root=", 10) == 0 ) {
|
||||||
|
arg += 10;
|
||||||
|
strcpy(fg_root, arg);
|
||||||
|
} else if ( strcmp(arg, "--disable-fog") == 0 ) {
|
||||||
|
fog = 0;
|
||||||
|
} else if ( strcmp(arg, "--enable-fog") == 0 ) {
|
||||||
|
fog = 1;
|
||||||
|
} else if ( strncmp(arg, "--fov=", 6) == 0 ) {
|
||||||
|
fov = parse_fov(arg);
|
||||||
|
} else if ( strcmp(arg, "--disable-fullscreen") == 0 ) {
|
||||||
|
fullscreen = 0;
|
||||||
|
} else if ( strcmp(arg, "--enable-fullscreen") == 0 ) {
|
||||||
|
fullscreen = 1;
|
||||||
|
} else if ( strcmp(arg, "--shading-flat") == 0 ) {
|
||||||
|
shading = 0;
|
||||||
|
} else if ( strcmp(arg, "--shading-smooth") == 0 ) {
|
||||||
|
shading = 1;
|
||||||
|
} else if ( strcmp(arg, "--disable-skyblend") == 0 ) {
|
||||||
|
skyblend = 0;
|
||||||
|
} else if ( strcmp(arg, "--enable-skyblend") == 0 ) {
|
||||||
|
skyblend = 1;
|
||||||
|
} else if ( strcmp(arg, "--disable-textures") == 0 ) {
|
||||||
|
textures = 0;
|
||||||
|
} else if ( strcmp(arg, "--enable-textures") == 0 ) {
|
||||||
|
textures = 1;
|
||||||
|
} else if ( strcmp(arg, "--disable-wireframe") == 0 ) {
|
||||||
|
wireframe = 0;
|
||||||
|
} else if ( strcmp(arg, "--enable-wireframe") == 0 ) {
|
||||||
|
wireframe = 1;
|
||||||
|
} else if ( strncmp(arg, "--tile-radius=", 14) == 0 ) {
|
||||||
|
tile_radius = parse_tile_radius(arg);
|
||||||
|
} else if ( strncmp(arg, "--time-offset=", 14) == 0 ) {
|
||||||
|
time_offset = parse_time_offset(arg);
|
||||||
|
} else {
|
||||||
|
return(FG_OPTIONS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("parse_int(): arg = %s\n", arg);
|
return(FG_OPTIONS_OK);
|
||||||
|
|
||||||
result = atoi(arg);
|
|
||||||
|
|
||||||
if ( result < min ) { result = min; }
|
|
||||||
if ( result > max ) { result = max; }
|
|
||||||
|
|
||||||
printf("parse_int(): result = %d\n", result);
|
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Parse the command line options
|
// Parse the command line options
|
||||||
int fgOPTIONS::parse( int argc, char **argv ) {
|
int fgOPTIONS::parse_command_line( int argc, char **argv ) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
int result;
|
||||||
|
|
||||||
fgPrintf(FG_GENERAL, FG_INFO, "Processing arguments\n");
|
fgPrintf(FG_GENERAL, FG_INFO, "Processing command line arguments\n");
|
||||||
|
|
||||||
while ( i < argc ) {
|
while ( i < argc ) {
|
||||||
fgPrintf(FG_GENERAL, FG_INFO, "argv[%d] = %s\n", i, argv[i]);
|
fgPrintf(FG_GENERAL, FG_INFO, "argv[%d] = %s\n", i, argv[i]);
|
||||||
|
|
||||||
// General Options
|
result = parse_option(argv[i]);
|
||||||
if ( (strcmp(argv[i], "--help") == 0) ||
|
if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
|
||||||
(strcmp(argv[i], "-h") == 0) ) {
|
return(result);
|
||||||
// help/usage request
|
|
||||||
return(FG_OPTIONS_HELP);
|
|
||||||
} else if ( strcmp(argv[i], "--disable-hud") == 0 ) {
|
|
||||||
hud_status = 0;
|
|
||||||
} else if ( strcmp(argv[i], "--enable-hud") == 0 ) {
|
|
||||||
hud_status = 1;
|
|
||||||
} else if ( strncmp(argv[i], "--airport-id=", 13) == 0 ) {
|
|
||||||
argv[i] += 13;
|
|
||||||
strncpy(airport_id, argv[i], 4);
|
|
||||||
} else if ( strcmp(argv[i], "--disable-fog") == 0 ) {
|
|
||||||
fog = 0;
|
|
||||||
} else if ( strcmp(argv[i], "--enable-fog") == 0 ) {
|
|
||||||
fog = 1;
|
|
||||||
} else if ( strcmp(argv[i], "--disable-fullscreen") == 0 ) {
|
|
||||||
fullscreen = 0;
|
|
||||||
} else if ( strcmp(argv[i], "--enable-fullscreen") == 0 ) {
|
|
||||||
fullscreen = 1;
|
|
||||||
} else if ( strcmp(argv[i], "--shading-flat") == 0 ) {
|
|
||||||
shading = 0;
|
|
||||||
} else if ( strcmp(argv[i], "--shading-smooth") == 0 ) {
|
|
||||||
shading = 1;
|
|
||||||
} else if ( strcmp(argv[i], "--disable-skyblend") == 0 ) {
|
|
||||||
skyblend = 0;
|
|
||||||
} else if ( strcmp(argv[i], "--enable-skyblend") == 0 ) {
|
|
||||||
skyblend = 1;
|
|
||||||
} else if ( strcmp(argv[i], "--disable-textures") == 0 ) {
|
|
||||||
textures = 0;
|
|
||||||
} else if ( strcmp(argv[i], "--enable-textures") == 0 ) {
|
|
||||||
textures = 1;
|
|
||||||
} else if ( strcmp(argv[i], "--disable-wireframe") == 0 ) {
|
|
||||||
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, 9);
|
|
||||||
} else if ( strncmp(argv[i], "--time-offset=", 14) == 0 ) {
|
|
||||||
time_offset = parse_time_offset(argv[i]);
|
|
||||||
} else {
|
|
||||||
return(FG_OPTIONS_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
@ -248,6 +350,44 @@ int fgOPTIONS::parse( int argc, char **argv ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parse the command line options
|
||||||
|
int fgOPTIONS::parse_config_file( char *path ) {
|
||||||
|
char fgpath[256], line[256];
|
||||||
|
fgFile f;
|
||||||
|
int len, result;
|
||||||
|
|
||||||
|
strcpy(fgpath, path);
|
||||||
|
strcat(fgpath, ".gz");
|
||||||
|
|
||||||
|
// first try "path.gz"
|
||||||
|
if ( (f = fgopen(fgpath, "rb")) == NULL ) {
|
||||||
|
// next try "path"
|
||||||
|
if ( (f = fgopen(path, "rb")) == NULL ) {
|
||||||
|
return(FG_OPTIONS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fgPrintf(FG_GENERAL, FG_INFO, "Processing config file: %s\n", path);
|
||||||
|
|
||||||
|
while ( fggets(f, line, 250) != NULL ) {
|
||||||
|
// strip trailing newline if it exists
|
||||||
|
len = strlen(line);
|
||||||
|
if ( line[len-1] == '\n' ) {
|
||||||
|
line[len-1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
result = parse_option(line);
|
||||||
|
if ( result == FG_OPTIONS_ERROR ) {
|
||||||
|
fgPrintf( FG_GENERAL, FG_EXIT,
|
||||||
|
"Config file parse error: %s '%s'\n", path, line );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fgclose(f);
|
||||||
|
return(FG_OPTIONS_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Print usage message
|
// Print usage message
|
||||||
void fgOPTIONS::usage ( void ) {
|
void fgOPTIONS::usage ( void ) {
|
||||||
printf("Usage: fg [ options ... ]\n");
|
printf("Usage: fg [ options ... ]\n");
|
||||||
|
@ -255,6 +395,7 @@ void fgOPTIONS::usage ( void ) {
|
||||||
|
|
||||||
printf("General Options:\n");
|
printf("General Options:\n");
|
||||||
printf("\t--help -h: print usage\n");
|
printf("\t--help -h: print usage\n");
|
||||||
|
printf("\t--fg-root=path: specify the root path for all the data files\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("Features:\n");
|
printf("Features:\n");
|
||||||
|
@ -269,6 +410,7 @@ void fgOPTIONS::usage ( void ) {
|
||||||
printf("Rendering Options:\n");
|
printf("Rendering Options:\n");
|
||||||
printf("\t--disable-fog: disable fog/haze\n");
|
printf("\t--disable-fog: disable fog/haze\n");
|
||||||
printf("\t--enable-fog: enable fog/haze\n");
|
printf("\t--enable-fog: enable fog/haze\n");
|
||||||
|
printf("\t--fov=xx.x: specify the field of view angle in degrees\n");
|
||||||
printf("\t--disable-fullscreen: disable fullscreen mode\n");
|
printf("\t--disable-fullscreen: disable fullscreen mode\n");
|
||||||
printf("\t--enable-fullscreen: enable fullscreen mode\n");
|
printf("\t--enable-fullscreen: enable fullscreen mode\n");
|
||||||
printf("\t--shading-flat: enable flat shading\n");
|
printf("\t--shading-flat: enable flat shading\n");
|
||||||
|
@ -296,6 +438,13 @@ fgOPTIONS::~fgOPTIONS( void ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.9 1998/05/13 18:29:59 curt
|
||||||
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
|
// Added a command line option to specify fov.
|
||||||
|
// Adjusted terrain color.
|
||||||
|
// Root path info moved to fgOPTIONS.
|
||||||
|
// Added ability to parse options out of a config file.
|
||||||
|
//
|
||||||
// Revision 1.8 1998/05/07 23:14:16 curt
|
// Revision 1.8 1998/05/07 23:14:16 curt
|
||||||
// Added "D" key binding to set autopilot heading.
|
// Added "D" key binding to set autopilot heading.
|
||||||
// Made frame rate calculation average out over last 10 frames.
|
// Made frame rate calculation average out over last 10 frames.
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
class fgOPTIONS {
|
class fgOPTIONS {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// The flight gear "root" directory
|
||||||
|
char fg_root[256];
|
||||||
|
|
||||||
// ID of initial starting airport
|
// ID of initial starting airport
|
||||||
char airport_id[5];
|
char airport_id[5];
|
||||||
|
@ -49,6 +51,7 @@ public:
|
||||||
|
|
||||||
// Rendering options
|
// Rendering options
|
||||||
int fog; // Fog enabled/disabled
|
int fog; // Fog enabled/disabled
|
||||||
|
double fov; // Field of View
|
||||||
int fullscreen; // Full screen mode enabled/disabled
|
int fullscreen; // Full screen mode enabled/disabled
|
||||||
int shading; // shading method, 0 = Flat, 1 = Smooth
|
int shading; // shading method, 0 = Flat, 1 = Smooth
|
||||||
int skyblend; // Blend sky to haze (using polygons) or just clear
|
int skyblend; // Blend sky to haze (using polygons) or just clear
|
||||||
|
@ -67,8 +70,14 @@ public:
|
||||||
// Constructor
|
// Constructor
|
||||||
fgOPTIONS( void );
|
fgOPTIONS( void );
|
||||||
|
|
||||||
|
// Parse a single option
|
||||||
|
int parse_option( char *arg );
|
||||||
|
|
||||||
// Parse the command line options
|
// Parse the command line options
|
||||||
int parse( int argc, char **argv );
|
int parse_command_line( int argc, char **argv );
|
||||||
|
|
||||||
|
// Parse the command line options
|
||||||
|
int parse_config_file( char *path );
|
||||||
|
|
||||||
// Print usage message
|
// Print usage message
|
||||||
void usage ( void );
|
void usage ( void );
|
||||||
|
@ -86,6 +95,13 @@ extern fgOPTIONS current_options;
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.7 1998/05/13 18:29:59 curt
|
||||||
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
|
// Added a command line option to specify fov.
|
||||||
|
// Adjusted terrain color.
|
||||||
|
// Root path info moved to fgOPTIONS.
|
||||||
|
// Added ability to parse options out of a config file.
|
||||||
|
//
|
||||||
// Revision 1.6 1998/05/06 03:16:26 curt
|
// Revision 1.6 1998/05/06 03:16:26 curt
|
||||||
// Added an averaged global frame rate counter.
|
// Added an averaged global frame rate counter.
|
||||||
// Added an option to control tile radius.
|
// Added an option to control tile radius.
|
||||||
|
|
Loading…
Add table
Reference in a new issue