1
0
Fork 0

Type-ified fgTIME and fgVIEW.

Added a command line option to disable textures.
This commit is contained in:
curt 1998-04-28 01:20:20 +00:00
parent c0f121ab00
commit 7352183ad9
7 changed files with 109 additions and 49 deletions

View file

@ -55,8 +55,8 @@ extern int displayInstruments;
void GLUTkey(unsigned char k, int x, int y) { void GLUTkey(unsigned char k, int x, int y) {
fgCONTROLS *c; fgCONTROLS *c;
fgOPTIONS *o; fgOPTIONS *o;
struct fgTIME *t; fgTIME *t;
struct fgVIEW *v; fgVIEW *v;
struct fgWEATHER *w; struct fgWEATHER *w;
c = current_aircraft.controls; c = current_aircraft.controls;
@ -186,7 +186,7 @@ void GLUTkey(unsigned char k, int x, int y) {
/* Handle "special" keyboard events */ /* Handle "special" keyboard events */
void GLUTspecialkey(int k, int x, int y) { void GLUTspecialkey(int k, int x, int y) {
fgCONTROLS *c; fgCONTROLS *c;
struct fgVIEW *v; fgVIEW *v;
c = current_aircraft.controls; c = current_aircraft.controls;
v = &current_view; v = &current_view;
@ -265,9 +265,13 @@ void GLUTspecialkey(int k, int x, int y) {
/* $Log$ /* $Log$
/* Revision 1.5 1998/04/25 22:06:29 curt /* Revision 1.6 1998/04/28 01:20:20 curt
/* Edited cvs log messages in source files ... bad bad bad! /* Type-ified fgTIME and fgVIEW.
/* Added a command line option to disable textures.
/* /*
* Revision 1.5 1998/04/25 22:06:29 curt
* Edited cvs log messages in source files ... bad bad bad!
*
* Revision 1.4 1998/04/25 20:24:00 curt * Revision 1.4 1998/04/25 20:24:00 curt
* Cleaned up initialization sequence to eliminate interdependencies * Cleaned up initialization sequence to eliminate interdependencies
* between sun position, lighting, and view position. This creates a * between sun position, lighting, and view position. This creates a

View file

@ -214,12 +214,10 @@ static void fgInitVisuals( void ) {
static void fgUpdateViewParams( void ) { static void fgUpdateViewParams( void ) {
fgFLIGHT *f; fgFLIGHT *f;
fgLIGHT *l; fgLIGHT *l;
// struct fgTIME *t; fgVIEW *v;
struct fgVIEW *v;
f = current_aircraft.flight; f = current_aircraft.flight;
l = &cur_light_params; l = &cur_light_params;
// t = &cur_time_params;
v = &current_view; v = &current_view;
fgViewUpdate(f, v, l); fgViewUpdate(f, v, l);
@ -318,10 +316,11 @@ static void fgUpdateInstrViewParams( void ) {
static void fgRenderFrame( void ) { static void fgRenderFrame( void ) {
fgLIGHT *l; fgLIGHT *l;
fgOPTIONS *o; fgOPTIONS *o;
struct fgTIME *t; fgTIME *t;
struct fgVIEW *v; fgVIEW *v;
double angle; double angle;
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 };
l = &cur_light_params; l = &cur_light_params;
o = &current_options; o = &current_options;
@ -384,18 +383,25 @@ static void fgRenderFrame( void ) {
// set lighting parameters // set lighting parameters
xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient ); xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse ); xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
// texture parameters
xglEnable( GL_TEXTURE_2D ); /* xglDisable( GL_TEXTURE_2D ); */ if ( o->use_textures ) {
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ; // texture parameters
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ; xglEnable( GL_TEXTURE_2D );
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ) ; xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ;
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
GL_LINEAR /* GL_LINEAR_MIPMAP_LINEAR */ ) ; xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ) ;
xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ; xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ; GL_LINEAR /* GL_LINEAR_MIPMAP_LINEAR */ ) ;
// set base color (I don't think this is doing anything here) xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
xglMaterialfv (GL_FRONT, GL_AMBIENT, white); xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ;
xglMaterialfv (GL_FRONT, GL_DIFFUSE, white); // set base color (I don't think this is doing anything here)
xglMaterialfv (GL_FRONT, GL_AMBIENT, white);
xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
} else {
xglDisable( GL_TEXTURE_2D );
xglMaterialfv (GL_FRONT, GL_AMBIENT, color);
xglMaterialfv (GL_FRONT, GL_DIFFUSE, color);
}
fgTileMgrRender(); fgTileMgrRender();
@ -418,8 +424,8 @@ static void fgRenderFrame( void ) {
// Update internal time dependent calculations (i.e. flight model) // Update internal time dependent calculations (i.e. flight model)
void fgUpdateTimeDepCalcs(int multi_loop) { void fgUpdateTimeDepCalcs(int multi_loop) {
fgFLIGHT *f; fgFLIGHT *f;
struct fgTIME *t; fgTIME *t;
struct fgVIEW *v; fgVIEW *v;
int i; int i;
f = current_aircraft.flight; f = current_aircraft.flight;
@ -484,7 +490,7 @@ static void fgMainLoop( void ) {
// int joy_b1, joy_b2; // int joy_b1, joy_b2;
fgAIRCRAFT *a; fgAIRCRAFT *a;
fgFLIGHT *f; fgFLIGHT *f;
struct fgTIME *t; fgTIME *t;
fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n"); fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n"); fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
@ -693,6 +699,10 @@ extern "C" {
// $Log$ // $Log$
// Revision 1.8 1998/04/28 01:20:21 curt
// Type-ified fgTIME and fgVIEW.
// Added a command line option to disable textures.
//
// Revision 1.7 1998/04/26 05:10:02 curt // Revision 1.7 1998/04/26 05:10:02 curt
// "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd. // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
// //

View file

@ -119,9 +119,9 @@ int fgInitPosition( void ) {
// FG_Altitude = FG_Runway_altitude + 3.758099; // FG_Altitude = FG_Runway_altitude + 3.758099;
// Test Position // Test Position
// FG_Longitude = ( -109.5 ) * DEG_TO_RAD; // FG_Longitude = ( -110.5 ) * DEG_TO_RAD;
// FG_Latitude = ( 32.5 ) * DEG_TO_RAD; // FG_Latitude = ( 34.5 ) * DEG_TO_RAD;
// FG_Runway_altitude = (2646 + 2000); // FG_Runway_altitude = (2646 + 6000);
// FG_Altitude = FG_Runway_altitude + 3.758099; // FG_Altitude = FG_Runway_altitude + 3.758099;
if ( strlen(o->airport_id) ) { if ( strlen(o->airport_id) ) {
@ -190,8 +190,8 @@ int fgInitSubsystems( void ) {
fgFLIGHT *f; fgFLIGHT *f;
fgLIGHT *l; fgLIGHT *l;
struct fgTIME *t; fgTIME *t;
struct fgVIEW *v; fgVIEW *v;
l = &cur_light_params; l = &cur_light_params;
t = &cur_time_params; t = &cur_time_params;
@ -369,6 +369,10 @@ int fgInitSubsystems( void ) {
// $Log$ // $Log$
// Revision 1.7 1998/04/28 01:20:22 curt
// Type-ified fgTIME and fgVIEW.
// Added a command line option to disable textures.
//
// Revision 1.6 1998/04/26 05:10:03 curt // Revision 1.6 1998/04/26 05:10:03 curt
// "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd. // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
// //

View file

@ -48,6 +48,7 @@ fgOPTIONS::fgOPTIONS( void ) {
strcpy(airport_id, ""); strcpy(airport_id, "");
hud_status = 0; hud_status = 0;
time_offset = 0; time_offset = 0;
use_textures = 1;
} }
@ -158,17 +159,22 @@ int fgOPTIONS::parse( int argc, char **argv ) {
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]);
if ( strncmp(argv[i], "--airport-id=", 13) == 0 ) { // General Options
argv[i] += 13; if ( (strcmp(argv[i], "--help") == 0) ||
strncpy(airport_id, argv[i], 4); (strcmp(argv[i], "-h") == 0) ) {
// help/usage request
return(FG_OPTIONS_HELP);
} else if ( strcmp(argv[i], "--disable-hud") == 0 ) { } else if ( strcmp(argv[i], "--disable-hud") == 0 ) {
hud_status = 0; hud_status = 0;
} else if ( strcmp(argv[i], "--enable-hud") == 0 ) { } else if ( strcmp(argv[i], "--enable-hud") == 0 ) {
hud_status = 1; hud_status = 1;
} else if ( (strcmp(argv[i], "--help") == 0) || } else if ( strncmp(argv[i], "--airport-id=", 13) == 0 ) {
(strcmp(argv[i], "-h") == 0) ) { argv[i] += 13;
// help/usage request strncpy(airport_id, argv[i], 4);
return(FG_OPTIONS_HELP); } else if ( strcmp(argv[i], "--disable-textures") == 0 ) {
use_textures = 0;
} else if ( strcmp(argv[i], "--enable-textures") == 0 ) {
use_textures = 1;
} else if ( strncmp(argv[i], "--time-offset=", 14) == 0 ) { } else if ( strncmp(argv[i], "--time-offset=", 14) == 0 ) {
time_offset = parse_time_offset(argv[i]); time_offset = parse_time_offset(argv[i]);
} else { } else {
@ -185,10 +191,27 @@ int fgOPTIONS::parse( int argc, char **argv ) {
// Print usage message // Print usage message
void fgOPTIONS::usage ( void ) { void fgOPTIONS::usage ( void ) {
printf("Usage: fg [ options ... ]\n"); printf("Usage: fg [ options ... ]\n");
printf("\t--airport-id=ABCD: specify starting postion by airport id\n"); printf("\n");
printf("General Options:\n");
printf("\t--help -h: print usage\n");
printf("\n");
printf("Features:\n");
printf("\t--disable-hud: disable heads up display\n"); printf("\t--disable-hud: disable heads up display\n");
printf("\t--enable-hud: enable heads up display\n"); printf("\t--enable-hud: enable heads up display\n");
printf("\t--help -h: print usage\n"); printf("\n");
printf("Initial Position:\n");
printf("\t--airport-id=ABCD: specify starting postion by airport id\n");
printf("\n");
printf("Rendering Options:\n");
printf("\t--disable-textures: disable textures\n");
printf("\t--enable-textures: enable textures\n");
printf("\n");
printf("Time Options:\n");
printf("\t--time-offset=[+-]hh:mm:ss: offset local time by this amount\n"); printf("\t--time-offset=[+-]hh:mm:ss: offset local time by this amount\n");
} }
@ -199,6 +222,10 @@ fgOPTIONS::~fgOPTIONS( void ) {
// $Log$ // $Log$
// Revision 1.4 1998/04/28 01:20:22 curt
// Type-ified fgTIME and fgVIEW.
// Added a command line option to disable textures.
//
// Revision 1.3 1998/04/26 05:01:19 curt // Revision 1.3 1998/04/26 05:01:19 curt
// Added an rint() / HAVE_RINT check. // Added an rint() / HAVE_RINT check.
// //

View file

@ -50,6 +50,9 @@ public:
// Offset true time by this many seconds // Offset true time by this many seconds
int time_offset; int time_offset;
// Textures enabled/disabled
int use_textures;
// Constructor // Constructor
fgOPTIONS( void ); fgOPTIONS( void );
@ -72,6 +75,10 @@ extern fgOPTIONS current_options;
// $Log$ // $Log$
// Revision 1.3 1998/04/28 01:20:23 curt
// Type-ified fgTIME and fgVIEW.
// Added a command line option to disable textures.
//
// Revision 1.2 1998/04/25 15:11:13 curt // Revision 1.2 1998/04/25 15:11:13 curt
// Added an command line option to set starting position based on airport ID. // Added an command line option to set starting position based on airport ID.
// //

View file

@ -41,11 +41,11 @@
// This is a record containing current view parameters // This is a record containing current view parameters
struct fgVIEW current_view; fgVIEW current_view;
// Initialize a view structure // Initialize a view structure
void fgViewInit(struct fgVIEW *v) { void fgViewInit(fgVIEW *v) {
fgPrintf( FG_VIEW, FG_INFO, "Initializing View parameters\n"); fgPrintf( FG_VIEW, FG_INFO, "Initializing View parameters\n");
v->view_offset = 0.0; v->view_offset = 0.0;
@ -54,7 +54,7 @@ void fgViewInit(struct fgVIEW *v) {
// Update the view parameters // Update the view parameters
void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l) { void fgViewUpdate(fgFLIGHT *f, fgVIEW *v, fgLIGHT *l) {
MAT3vec vec, forward, v0, minus_z; MAT3vec vec, forward, v0, minus_z;
MAT3mat R, TMP, UP, LOCAL, VIEW; MAT3mat R, TMP, UP, LOCAL, VIEW;
double ntmp; double ntmp;
@ -200,6 +200,10 @@ void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l) {
// $Log$ // $Log$
// Revision 1.6 1998/04/28 01:20:23 curt
// Type-ified fgTIME and fgVIEW.
// Added a command line option to disable textures.
//
// Revision 1.5 1998/04/26 05:10:04 curt // Revision 1.5 1998/04/26 05:10:04 curt
// "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd. // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
// //

View file

@ -41,7 +41,7 @@
/* Define a structure containing view information */ /* Define a structure containing view information */
struct fgVIEW { typedef struct {
/* absolute view position */ /* absolute view position */
struct fgCartesianPoint abs_view_pos; struct fgCartesianPoint abs_view_pos;
@ -81,26 +81,30 @@ struct fgVIEW {
/* the goal view offset for viewing (used for smooth view changes) */ /* the goal view offset for viewing (used for smooth view changes) */
double goal_view_offset; double goal_view_offset;
}; } fgVIEW;
extern struct fgVIEW current_view; extern fgVIEW current_view;
/* Initialize a view structure */ /* Initialize a view structure */
void fgViewInit(struct fgVIEW *v); void fgViewInit(fgVIEW *v);
/* Update the view parameters */ /* Update the view parameters */
void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l); void fgViewUpdate(fgFLIGHT *f, fgVIEW *v, fgLIGHT *l);
#endif /* _VIEWS_HXX */ #endif /* _VIEWS_HXX */
/* $Log$ /* $Log$
/* Revision 1.3 1998/04/25 22:06:31 curt /* Revision 1.4 1998/04/28 01:20:24 curt
/* Edited cvs log messages in source files ... bad bad bad! /* Type-ified fgTIME and fgVIEW.
/* Added a command line option to disable textures.
/* /*
* Revision 1.3 1998/04/25 22:06:31 curt
* Edited cvs log messages in source files ... bad bad bad!
*
* Revision 1.2 1998/04/24 00:49:22 curt * Revision 1.2 1998/04/24 00:49:22 curt
* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H" * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
* Trying out some different option parsing code. * Trying out some different option parsing code.