diff --git a/Astro/orbits.cxx b/Astro/orbits.cxx index 5fc84e1f9..58521f1d5 100644 --- a/Astro/orbits.cxx +++ b/Astro/orbits.cxx @@ -111,16 +111,13 @@ int fgReadOrbElements(struct OrbElements *dest, gzFile src) { int fgSolarSystemInit(fgTIME t) { - fgOPTIONS *o; char path[256], gzpath[256]; int i, ret_val; fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n"); /* build the full path name to the orbital elements database file */ - o = ¤t_options; - path[0] = '\0'; - strcat(path, o->fg_root); + current_options.get_fg_root(path); strcat(path, "/Scenery/"); strcat(path, "Planets"); @@ -170,9 +167,12 @@ void fgSolarSystemUpdate(struct OrbElements *planet, fgTIME t) /* $Log$ -/* Revision 1.6 1998/05/29 20:35:41 curt -/* Added zlib support for reading in compressed data files. +/* Revision 1.7 1998/07/13 21:00:09 curt +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.6 1998/05/29 20:35:41 curt + * Added zlib support for reading in compressed data files. + * * Revision 1.5 1998/05/13 18:25:34 curt * Root path info moved to fgOPTIONS. * diff --git a/Astro/stars.cxx b/Astro/stars.cxx index f23ec49be..be7989eef 100644 --- a/Astro/stars.cxx +++ b/Astro/stars.cxx @@ -64,7 +64,6 @@ /* Initialize the Star Management Subsystem */ int fgStarsInit( void ) { fgFile fd; - fgOPTIONS *o; /* struct CelestialCoord pltPos; */ char path[256], gzpath[256]; char line[256], name[256]; @@ -76,11 +75,8 @@ int fgStarsInit( void ) { fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n"); - o = ¤t_options; - /* build the full path name to the stars data base file */ - path[0] = '\0'; - strcat(path, o->fg_root); + current_options.get_fg_root(path); strcat(path, "/Scenery/"); strcat(path, "Stars"); @@ -265,9 +261,12 @@ void fgStarsRender( void ) { /* $Log$ -/* Revision 1.7 1998/05/29 20:35:42 curt -/* Added zlib support for reading in compressed data files. +/* Revision 1.8 1998/07/13 21:00:10 curt +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.7 1998/05/29 20:35:42 curt + * Added zlib support for reading in compressed data files. + * * Revision 1.6 1998/05/13 18:25:35 curt * Root path info moved to fgOPTIONS. * diff --git a/GUI/gui.cxx b/GUI/gui.cxx index 093c754d3..8a4efb385 100644 --- a/GUI/gui.cxx +++ b/GUI/gui.cxx @@ -133,16 +133,14 @@ puCallback helpSubmenuCb [] = { notCb, notCb, NULL }; void guiInit() { fgGENERAL *g; - fgOPTIONS *o; char *mesa_win_state; g = &general; - o = ¤t_options; // Initialize PUI puInit(); - if ( o->mouse_pointer == 0 ) { + if ( current_options.get_mouse_pointer() == 0 ) { // no preference specified for mouse pointer, attempt to autodetect... // Determine if we need to render the cursor, or if the windowing // system will do it. First test if we are rendering with glide. @@ -156,9 +154,9 @@ void guiInit() } } } - } else if ( o->mouse_pointer == 1 ) { + } else if ( current_options.get_mouse_pointer() == 1 ) { // don't show pointer - } else if ( o->mouse_pointer == 2 ) { + } else if ( current_options.get_mouse_pointer() == 2 ) { // force showing pointer puShowCursor(); } diff --git a/Main/GLUTkey.cxx b/Main/GLUTkey.cxx index 1bd4e953b..c176504fe 100644 --- a/Main/GLUTkey.cxx +++ b/Main/GLUTkey.cxx @@ -57,14 +57,13 @@ /* Handle keyboard events */ void GLUTkey(unsigned char k, int x, int y) { fgCONTROLS *c; - fgOPTIONS *o; fgTIME *t; fgVIEW *v; struct fgWEATHER *w; - float tmp; + float fov, tmp; + int status; c = current_aircraft.controls; - o = ¤t_options; t = &cur_time_params; v = ¤t_view; w = ¤t_weather; @@ -100,7 +99,8 @@ void GLUTkey(unsigned char k, int x, int y) { v->goal_view_offset = FG_PI * 1.75; return; case 72: /* H key */ - o->hud_status = !(o->hud_status); + status = current_options.get_hud_status(); + current_options.set_hud_status(!status); return; case 77: /* M key */ t->warp -= 60; @@ -115,10 +115,12 @@ void GLUTkey(unsigned char k, int x, int y) { #endif return; case 88: /* X key */ - o->fov *= 1.05; - if ( o->fov > FG_FOV_MAX ) { - o->fov = FG_FOV_MAX; + fov = current_options.get_fov(); + fov *= 1.05; + if ( fov > FG_FOV_MAX ) { + fov = FG_FOV_MAX; } + current_options.set_fov(fov); v->update_fov = TRUE; return; case 90: /* Z key */ @@ -182,10 +184,12 @@ void GLUTkey(unsigned char k, int x, int y) { t->warp_delta += 30; return; case 120: /* X key */ - o->fov /= 1.05; - if ( o->fov < FG_FOV_MIN ) { - o->fov = FG_FOV_MIN; + fov = current_options.get_fov(); + fov /= 1.05; + if ( fov < FG_FOV_MIN ) { + fov = FG_FOV_MIN; } + current_options.set_fov(fov); v->update_fov = TRUE; return; case 122: /* z key */ @@ -294,18 +298,21 @@ void GLUTspecialkey(int k, int x, int y) { /* $Log$ -/* Revision 1.14 1998/07/06 02:42:02 curt -/* Added support for switching between fullscreen and window mode for -/* Mesa/3dfx/glide. -/* -/* Added a basic splash screen. Restructured the main loop and top level -/* initialization routines to do this. -/* -/* Hacked in some support for playing a startup mp3 sound file while rest -/* of sim initializes. Currently only works in Unix using the mpg123 player. -/* Waits for the mpg123 player to finish before initializing internal -/* sound drivers. +/* Revision 1.15 1998/07/13 21:01:34 curt +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.14 1998/07/06 02:42:02 curt + * Added support for switching between fullscreen and window mode for + * Mesa/3dfx/glide. + * + * Added a basic splash screen. Restructured the main loop and top level + * initialization routines to do this. + * + * Hacked in some support for playing a startup mp3 sound file while rest + * of sim initializes. Currently only works in Unix using the mpg123 player. + * Waits for the mpg123 player to finish before initializing internal + * sound drivers. + * * Revision 1.13 1998/06/27 16:54:32 curt * Replaced "extern displayInstruments" with a entry in fgOPTIONS. * Don't change the view port when displaying the panel. diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx index ecfa2b718..bea6d4215 100644 --- a/Main/GLUTmain.cxx +++ b/Main/GLUTmain.cxx @@ -130,15 +130,13 @@ slSample *s2; // fgInitVisuals() -- Initialize various GL/view parameters static void fgInitVisuals( void ) { fgLIGHT *l; - fgOPTIONS *o; struct fgWEATHER *w; l = &cur_light_params; - o = ¤t_options; w = ¤t_weather; // Go full screen if requested ... - if ( o->fullscreen ) { + if ( current_options.get_fullscreen() ) { glutFullScreen(); } @@ -154,13 +152,14 @@ static void fgInitVisuals( void ) { xglFogi (GL_FOG_MODE, GL_EXP2); // Fog density is now set when the weather system is initialized // xglFogf (GL_FOG_DENSITY, w->fog_density); - if ( (o->fog == 1) || (o->shading == 0) ) { + if ( (current_options.get_fog() == 1) || + (current_options.get_shading() == 0) ) { // if fastest fog requested, or if flat shading force fastest xglHint (GL_FOG_HINT, GL_FASTEST ); - } else if ( o->fog == 2 ) { + } else if ( current_options.get_fog() == 2 ) { xglHint (GL_FOG_HINT, GL_NICEST ); } - if ( o->wireframe ) { + if ( current_options.get_wireframe() ) { // draw wire frame xglPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); } @@ -174,12 +173,10 @@ static void fgInitVisuals( void ) { static void fgUpdateViewParams( void ) { fgFLIGHT *f; fgLIGHT *l; - fgOPTIONS *o; fgVIEW *v; f = current_aircraft.flight; l = &cur_light_params; - o = ¤t_options; v = ¤t_view; v->Update(f); @@ -198,9 +195,9 @@ static void fgUpdateViewParams( void ) { xglMatrixMode(GL_PROJECTION); xglLoadIdentity(); if ( FG_Altitude * FEET_TO_METER - scenery.cur_elev > 10.0 ) { - gluPerspective(o->fov, v->win_ratio, 10.0, 100000.0); + gluPerspective(current_options.get_fov(), v->win_ratio, 10.0, 100000.0); } else { - gluPerspective(o->fov, v->win_ratio, 1.0, 100000.0); + gluPerspective(current_options.get_fov(), v->win_ratio, 1.0, 100000.0); // printf("Near ground, minimizing near clip plane\n"); } // } @@ -293,7 +290,6 @@ static void fgUpdateInstrViewParams( void ) { static void fgRenderFrame( void ) { fgFLIGHT *f; fgLIGHT *l; - fgOPTIONS *o; fgTIME *t; fgVIEW *v; double angle; @@ -304,13 +300,12 @@ static void fgRenderFrame( void ) { f = current_aircraft.flight; l = &cur_light_params; - o = ¤t_options; t = &cur_time_params; v = ¤t_view; if ( idle_state != 1000 ) { // still initializing, draw the splash screen - if ( o->splash_screen == 1 ) { + if ( current_options.get_splash_screen() == 1 ) { fgSplashUpdate(0.0); } } else { @@ -329,10 +324,10 @@ static void fgRenderFrame( void ) { fgUpdateViewParams(); clear_mask = GL_DEPTH_BUFFER_BIT; - if ( o->wireframe ) { + if ( current_options.get_wireframe() ) { clear_mask |= GL_COLOR_BUFFER_BIT; } - if ( o->skyblend ) { + if ( current_options.get_skyblend() ) { glClearColor(black[0], black[1], black[2], black[3]); } else { glClearColor(l->sky_color[0], l->sky_color[1], @@ -351,7 +346,7 @@ static void fgRenderFrame( void ) { xglDisable( GL_CULL_FACE ); xglDisable( GL_FOG ); xglShadeModel( GL_SMOOTH ); - if ( o->skyblend ) { + if ( current_options.get_skyblend() ) { fgSkyRender(); } @@ -388,13 +383,13 @@ static void fgRenderFrame( void ) { xglPopMatrix(); // draw scenery - if ( o->shading ) { + if ( current_options.get_shading() ) { xglShadeModel( GL_SMOOTH ); } else { xglShadeModel( GL_FLAT ); } xglEnable( GL_DEPTH_TEST ); - if ( o->fog > 0 ) { + if ( current_options.get_fog() > 0 ) { xglEnable( GL_FOG ); xglFogfv (GL_FOG_COLOR, l->fog_color); } @@ -402,7 +397,7 @@ static void fgRenderFrame( void ) { xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient ); xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse ); - if ( o->textures ) { + if ( current_options.get_textures() ) { // texture parameters xglEnable( GL_TEXTURE_2D ); xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ; @@ -635,18 +630,16 @@ static void fgMainLoop( void ) { static void fgIdleFunction ( void ) { fgGENERAL *g; - fgOPTIONS *o; char path[256], mp3file[256], command[256], slfile[256]; static char *lockfile = "/tmp/mpg123.running"; g = &general; - o = ¤t_options; // printf("idle state == %d\n", idle_state); if ( idle_state == 0 ) { // Initialize the splash screen right away - if ( o->splash_screen ) { + if ( current_options.get_splash_screen() ) { fgSplashInit(); } @@ -654,8 +647,8 @@ static void fgIdleFunction ( void ) { } else if ( idle_state == 1 ) { // Start the intro music #if !defined(WIN32) - if ( o->intro_music ) { - strcpy(mp3file, o->fg_root); + if ( current_options.get_intro_music() ) { + current_options.get_fg_root(mp3file); strcat(mp3file, "/Sounds/"); strcat(mp3file, "intro.mp3"); sprintf(command, @@ -714,7 +707,7 @@ static void fgIdleFunction ( void ) { #ifdef HAVE_AUDIO_SUPPORT #if !defined(WIN32) - if ( o->intro_music ) { + if ( current_options.get_intro_music() ) { // Let's wait for mpg123 to finish struct stat stat_buf; @@ -733,7 +726,7 @@ static void fgIdleFunction ( void ) { audio_mixer = new smMixer; audio_mixer -> setMasterVolume ( 30 ) ; /* 50% of max volume. */ audio_sched -> setSafetyMargin ( 1.0 ) ; - strcpy(path, o->fg_root); + current_options.get_fg_root(path); strcat(path, "/Sounds/"); strcpy(slfile, path); @@ -762,7 +755,7 @@ static void fgIdleFunction ( void ) { fgMainLoop(); } else { - if ( o->splash_screen == 1 ) { + if ( current_options.get_splash_screen() == 1 ) { fgSplashUpdate(0.0); } } @@ -844,12 +837,10 @@ int fgGlutInitEvents( void ) { // Main ... int main( int argc, char **argv ) { fgFLIGHT *f; - fgOPTIONS *o; char config[256]; int result; // Used in command line argument. f = current_aircraft.flight; - o = ¤t_options; #ifdef HAVE_BC5PLUS _control87(MCW_EM, MCW_EM); /* defined in float.h */ @@ -873,24 +864,24 @@ int main( int argc, char **argv ) { // Attempt to locate and parse a config file // First check fg_root - strcpy(config, o->fg_root); + current_options.get_fg_root(config); strcat(config, "/system.fgfsrc"); - result = o->parse_config_file(config); + result = current_options.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); + result = current_options.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); + result = current_options.parse_command_line(argc, argv); if ( result != FG_OPTIONS_OK ) { // Something must have gone horribly wrong with the command // line parsing or maybe the user just requested help ... :-) - o->usage(); + current_options.usage(); fgPrintf( FG_GENERAL, FG_EXIT, "\nExiting ...\n"); } @@ -903,6 +894,9 @@ int main( int argc, char **argv ) { // $Log$ +// Revision 1.35 1998/07/13 21:01:36 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.34 1998/07/13 15:32:37 curt // Clear color buffer if drawing wireframe. // When specifying and airport, start elevation at -1000 and let the system diff --git a/Main/airports.cxx b/Main/airports.cxx index 5652916b1..0baa23d42 100644 --- a/Main/airports.cxx +++ b/Main/airports.cxx @@ -42,16 +42,13 @@ fgAIRPORTS::fgAIRPORTS( void ) { // load the data int fgAIRPORTS::load( char *file ) { fgAIRPORT a; - fgOPTIONS *o; char path[256], fgpath[256], line[256]; char id[5]; string id_str; fgFile f; - o = ¤t_options; - // build the path name to the airport file - strcpy(path, o->fg_root); + current_options.get_fg_root(path); strcat(path, "/Scenery/"); strcat(path, "Airports"); strcpy(fgpath, path); @@ -103,6 +100,9 @@ fgAIRPORTS::~fgAIRPORTS( void ) { // $Log$ +// Revision 1.8 1998/07/13 21:01:37 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.7 1998/06/03 22:01:07 curt // Tweaking sound library usage. // diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx index cb5bb2236..379154480 100644 --- a/Main/fg_init.cxx +++ b/Main/fg_init.cxx @@ -65,18 +65,17 @@ extern const char *default_root; // Set initial position int fgInitPosition( void ) { + char id[5]; fgFLIGHT *f; - fgOPTIONS *o; f = current_aircraft.flight; - o = ¤t_options; // If nothing else is specified, default initial position is // Globe, AZ (P13) FG_Longitude = ( -110.6642444 ) * DEG_TO_RAD; FG_Latitude = ( 33.3528917 ) * DEG_TO_RAD; - FG_Runway_altitude = (3234.5 + 300); - FG_Altitude = FG_Runway_altitude + 3.758099; + FG_Runway_altitude = (3234.5); + FG_Altitude = -1000 /* FG_Runway_altitude + 3.758099 */; // Initial Position north of the city of Globe // FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD; @@ -133,24 +132,25 @@ int fgInitPosition( void ) { // Test Position // 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; + // FG_Runway_altitude = ( 6000 ); + // FG_Altitude = FG_Runway_altitude + 3.758099; - if ( strlen(o->airport_id) ) { + current_options.get_airport_id(id); + if ( strlen(id) ) { fgAIRPORTS airports; fgAIRPORT a; fgPrintf( FG_GENERAL, FG_INFO, "Attempting to set starting position from airport code %s.\n", - o->airport_id); + id); airports.load("Airports"); - a = airports.search(o->airport_id); + a = airports.search(id); if ( (fabs(a.longitude) < FG_EPSILON) && (fabs(a.latitude) < FG_EPSILON) && (fabs(a.elevation) < FG_EPSILON) ) { fgPrintf( FG_GENERAL, FG_EXIT, - "Failed to find %s in database.\n", o->airport_id); + "Failed to find %s in database.\n", id); } else { FG_Longitude = ( a.longitude ) * DEG_TO_RAD; FG_Latitude = ( a.latitude ) * DEG_TO_RAD; @@ -171,11 +171,10 @@ int fgInitPosition( void ) { // General house keeping initializations int fgInitGeneral( void ) { fgGENERAL *g; - fgOPTIONS *o; + char root[256]; int i; g = &general; - o = ¤t_options; fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" ); fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" ); @@ -184,14 +183,14 @@ int fgInitGeneral( void ) { g->glRenderer = glGetString ( GL_RENDERER ); g->glVersion = glGetString ( GL_VERSION ); - if ( !strlen(o->fg_root) ) { - // No root path set? Then assume, we will exit if this is - // wrong when looking for support files. + current_options.get_fg_root(root); + if ( !strlen(root) ) { + // No root path set? Then bail ... 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", o->fg_root); + fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", root); // prime the frame rate counter pump for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) { @@ -395,6 +394,9 @@ int fgInitSubsystems( void ) { // $Log$ +// Revision 1.25 1998/07/13 21:01:38 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.24 1998/07/13 15:32:39 curt // Clear color buffer if drawing wireframe. // When specifying and airport, start elevation at -1000 and let the system diff --git a/Main/options.cxx b/Main/options.cxx index 02c74ca83..5e3b9ff40 100644 --- a/Main/options.cxx +++ b/Main/options.cxx @@ -458,12 +458,39 @@ void fgOPTIONS::usage ( void ) { } +// Query functions +void fgOPTIONS::get_fg_root(char *root) { strcpy(root, fg_root); } +void fgOPTIONS::get_airport_id(char *id) { strcpy(id, airport_id); } +int fgOPTIONS::get_splash_screen( void ) { return(splash_screen); } +int fgOPTIONS::get_intro_music( void ) { return(intro_music); } +int fgOPTIONS::get_mouse_pointer( void ) { return(mouse_pointer); } +int fgOPTIONS::get_hud_status( void ) { return(hud_status); } +int fgOPTIONS::get_panel_status( void ) { return(panel_status); } +int fgOPTIONS::get_fog( void ) { return(fog); } +double fgOPTIONS::get_fov( void ) { return(fov); } +int fgOPTIONS::get_fullscreen( void ) { return(fullscreen); } +int fgOPTIONS::get_shading( void ) { return(shading); } +int fgOPTIONS::get_skyblend( void ) { return(skyblend); } +int fgOPTIONS::get_textures( void ) { return(textures); } +int fgOPTIONS::get_wireframe( void ) { return(wireframe); } +int fgOPTIONS::get_tile_radius( void ) { return(tile_radius); } +int fgOPTIONS::get_tile_diameter( void ) { return(tile_diameter); } +int fgOPTIONS::get_time_offset( void ) { return(time_offset); } + + +// Update functions +void fgOPTIONS::set_hud_status( int status ) { hud_status = status; } +void fgOPTIONS::set_fov( double amount ) { fov = amount; } + // Destructor fgOPTIONS::~fgOPTIONS( void ) { } // $Log$ +// Revision 1.16 1998/07/13 21:01:39 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.15 1998/07/06 21:34:19 curt // Added an enable/disable splash screen option. // Added an enable/disable intro music option. diff --git a/Main/options.hxx b/Main/options.hxx index b01a63135..142d324ce 100644 --- a/Main/options.hxx +++ b/Main/options.hxx @@ -39,7 +39,6 @@ class fgOPTIONS { -public: // The flight gear "root" directory char fg_root[256]; @@ -75,6 +74,8 @@ public: // Time options int time_offset; // Offset true time by this many seconds +public: + // Constructor fgOPTIONS( void ); @@ -90,6 +91,29 @@ public: // Print usage message void usage ( void ); + // Query functions + void get_fg_root(char *root); + void get_airport_id(char *id); + int get_splash_screen( void ); + int get_intro_music( void ); + int get_mouse_pointer( void ); + int get_hud_status( void ); + int get_panel_status( void ); + int get_fog( void ); + double get_fov( void ); + int get_fullscreen( void ); + int get_shading( void ); + int get_skyblend( void ); + int get_textures( void ); + int get_wireframe( void ); + int get_tile_radius( void ); + int get_tile_diameter( void ); + int get_time_offset( void ); + + // Update functions + void set_hud_status( int status ); + void set_fov( double amount ); + // Destructor ~fgOPTIONS( void ); @@ -103,6 +127,9 @@ extern fgOPTIONS current_options; // $Log$ +// Revision 1.11 1998/07/13 21:01:39 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.10 1998/07/06 21:34:20 curt // Added an enable/disable splash screen option. // Added an enable/disable intro music option. diff --git a/Main/splash.cxx b/Main/splash.cxx index 46770010f..c295997fa 100644 --- a/Main/splash.cxx +++ b/Main/splash.cxx @@ -50,12 +50,9 @@ static GLubyte *splash_texbuf; // Initialize the splash screen void fgSplashInit ( void ) { - fgOPTIONS *o; char tpath[256], fg_tpath[256]; int width, height; - o = ¤t_options; - fgPrintf( FG_GENERAL, FG_INFO, "Initializing splash screen\n"); #ifdef GL_VERSION_1_1 xglGenTextures(1, &splash_texid); @@ -73,8 +70,7 @@ void fgSplashInit ( void ) { xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // load in the texture data - tpath[0] = '\0'; - strcat(tpath, o->fg_root); + current_options.get_fg_root(tpath); strcat(tpath, "/Textures/"); strcat(tpath, "Splash2.rgb"); @@ -147,6 +143,9 @@ void fgSplashUpdate ( double progress ) { // $Log$ +// Revision 1.2 1998/07/13 21:01:40 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.1 1998/07/06 02:42:36 curt // Initial revision. // diff --git a/Main/views.cxx b/Main/views.cxx index 903e694db..bd9c4b99c 100644 --- a/Main/views.cxx +++ b/Main/views.cxx @@ -65,11 +65,13 @@ void fgVIEW::Init( void ) { // Update the field of view parameters void fgVIEW::UpdateFOV( fgOPTIONS *o ) { - double theta_x, theta_y; + double fov, theta_x, theta_y; + + fov = o->get_fov(); // printf("win_ratio = %.2f\n", win_ratio); // calculate sin() and cos() of fov / 2 in X direction; - theta_x = (o->fov * win_ratio * DEG_TO_RAD) / 2.0; + theta_x = (fov * win_ratio * DEG_TO_RAD) / 2.0; // printf("theta_x = %.2f\n", theta_x); sin_fov_x = sin(theta_x); cos_fov_x = cos(theta_x); @@ -77,7 +79,7 @@ void fgVIEW::UpdateFOV( fgOPTIONS *o ) { // printf("slope_x = %.2f\n", slope_x); // calculate sin() and cos() of fov / 2 in Y direction; - theta_y = (o->fov * DEG_TO_RAD) / 2.0; + theta_y = (fov * DEG_TO_RAD) / 2.0; // printf("theta_y = %.2f\n", theta_y); sin_fov_y = sin(theta_y); cos_fov_y = cos(theta_y); @@ -88,17 +90,14 @@ void fgVIEW::UpdateFOV( fgOPTIONS *o ) { // Update the view parameters void fgVIEW::Update( fgFLIGHT *f ) { - fgOPTIONS *o; fgPoint3d p; MAT3vec vec, forward, v0, minus_z; MAT3mat R, TMP, UP, LOCAL, VIEW; double ntmp; - o = ¤t_options; - if(update_fov == TRUE) { // printf("Updating fov\n"); - UpdateFOV(o); + UpdateFOV(¤t_options); update_fov = FALSE; } @@ -464,6 +463,9 @@ void fg_gluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez, // $Log$ +// Revision 1.16 1998/07/13 21:01:41 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.15 1998/07/12 03:14:43 curt // Added ground collision detection. // Did some serious horsing around to be able to "hug" the ground properly diff --git a/Scenery/material.cxx b/Scenery/material.cxx index abbd6ed72..f52bff036 100644 --- a/Scenery/material.cxx +++ b/Scenery/material.cxx @@ -71,7 +71,6 @@ fgMATERIAL_MGR::fgMATERIAL_MGR ( void ) { // Load a library of material properties int fgMATERIAL_MGR::load_lib ( void ) { fgMATERIAL m; - fgOPTIONS *o; char material_name[256]; char mpath[256], fg_mpath[256], tpath[256], fg_tpath[256]; char line[256], *line_ptr, value[256]; @@ -80,11 +79,8 @@ int fgMATERIAL_MGR::load_lib ( void ) { int width, height; int alpha; - o = ¤t_options; - // build the path name to the material db - mpath[0] = '\0'; - strcat(mpath, o->fg_root); + current_options.get_fg_root(mpath); strcat(mpath, "/Scenery/"); strcat(mpath, "Materials"); strcpy(fg_mpath, mpath); @@ -174,8 +170,7 @@ int fgMATERIAL_MGR::load_lib ( void ) { GL_LINEAR_MIPMAP_LINEAR ) ; /* load in the texture data */ - tpath[0] = '\0'; - strcat(tpath, o->fg_root); + current_options.get_fg_root(tpath); strcat(tpath, "/Textures/"); strcat(tpath, m.texture_name); strcat(tpath, ".rgb"); @@ -299,6 +294,9 @@ fgMATERIAL_MGR::~fgMATERIAL_MGR ( void ) { // $Log$ +// Revision 1.9 1998/07/13 21:01:57 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.8 1998/07/08 14:47:20 curt // Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen. // polare3d.h renamed to polar3d.hxx diff --git a/Scenery/obj.cxx b/Scenery/obj.cxx index fca63e6ff..dc544b33f 100644 --- a/Scenery/obj.cxx +++ b/Scenery/obj.cxx @@ -104,7 +104,6 @@ fgPoint3d calc_tex_coords(double *node, fgPoint3d *ref) { // Load a .obj file and build the GL fragment list int fgObjLoad(char *path, fgTILE *t) { - fgOPTIONS *o; fgFRAGMENT fragment; fgPoint3d pp; char fgpath[256], line[256], material[256]; @@ -113,11 +112,10 @@ int fgObjLoad(char *path, fgTILE *t) { // GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 }; GLint display_list; fgFile f; + int shading; int in_fragment, in_faces, vncount, n1, n2, n3, n4; int last1, last2, odd; - o = ¤t_options; - // First try "path.gz" (compressed format) strcpy(fgpath, path); strcat(fgpath, ".gz"); @@ -136,6 +134,8 @@ int fgObjLoad(char *path, fgTILE *t) { } } + shading = current_options.get_shading(); + in_fragment = 0; t->ncount = 1; vncount = 1; @@ -254,7 +254,7 @@ int fgObjLoad(char *path, fgTILE *t) { odd = 1; scale = 1.0; - if ( o->shading ) { + if ( shading ) { // Shading model is "GL_SMOOTH" so use precalculated // (averaged) normals MAT3_SCALE_VEC(normal, normals[n1], scale); @@ -307,7 +307,7 @@ int fgObjLoad(char *path, fgTILE *t) { if ( n4 > 0 ) { fragment.add_face(n3, n2, n4); - if ( o->shading ) { + if ( shading ) { // Shading model is "GL_SMOOTH" MAT3_SCALE_VEC(normal, normals[n4], scale); } else { @@ -367,7 +367,7 @@ int fgObjLoad(char *path, fgTILE *t) { fragment.add_face(last2, last1, n1); } - if ( o->shading ) { + if ( shading ) { // Shading model is "GL_SMOOTH" MAT3_SCALE_VEC(normal, normals[n1], scale); xglNormal3dv(normal); @@ -401,7 +401,7 @@ int fgObjLoad(char *path, fgTILE *t) { fragment.add_face(last2, last1, n2); } - if ( o->shading ) { + if ( shading ) { // Shading model is "GL_SMOOTH" MAT3_SCALE_VEC(normal, normals[n2], scale); xglNormal3dv(normal); @@ -466,6 +466,9 @@ int fgObjLoad(char *path, fgTILE *t) { // $Log$ +// Revision 1.19 1998/07/13 21:01:58 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.18 1998/07/12 03:18:27 curt // Added ground collision detection. This involved: // - saving the entire vertex list for each tile with the tile records. diff --git a/Scenery/scenery.cxx b/Scenery/scenery.cxx index 395d3f5cc..54ca3eed4 100644 --- a/Scenery/scenery.cxx +++ b/Scenery/scenery.cxx @@ -75,24 +75,7 @@ int fgSceneryInit( void ) { /* Tell the scenery manager where we are so it can load the proper data, and * build the proper structures. */ void fgSceneryUpdate(double lon, double lat, double elev) { - fgOPTIONS *o; - // double max_radius; - char path[1024]; - - o = ¤t_options; - - /* a hardcoded hack follows */ - - /* this routine should parse the file, and make calls back to the - * scenery management system to build the appropriate structures */ - path[0] = '\0'; - strcat(path, o->fg_root); - strcat(path, "/Scenery/"); - strcat(path, "mesa-e.obj"); - - // fgPrintf(FG_TERRAIN, FG_DEBUG, " Loading Scenery: %s\n", path); - - // area_terrain = fgObjLoad(path, &scenery.center, &max_radius); + // does nothing; } @@ -102,14 +85,17 @@ void fgSceneryRender( void ) { /* $Log$ -/* Revision 1.6 1998/07/12 03:18:27 curt -/* Added ground collision detection. This involved: -/* - saving the entire vertex list for each tile with the tile records. -/* - saving the face list for each fragment with the fragment records. -/* - code to intersect the current vertical line with the proper face in -/* an efficient manner as possible. -/* Fixed a bug where the tiles weren't being shifted to "near" (0,0,0) +/* Revision 1.7 1998/07/13 21:01:59 curt +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.6 1998/07/12 03:18:27 curt + * Added ground collision detection. This involved: + * - saving the entire vertex list for each tile with the tile records. + * - saving the face list for each fragment with the fragment records. + * - code to intersect the current vertical line with the proper face in + * an efficient manner as possible. + * Fixed a bug where the tiles weren't being shifted to "near" (0,0,0) + * * Revision 1.5 1998/06/17 21:36:41 curt * Load and manage multiple textures defined in the Materials library. * Boost max material fagments for each material property to 800. diff --git a/Scenery/tilecache.cxx b/Scenery/tilecache.cxx index c870ca7a7..e4457e46e 100644 --- a/Scenery/tilecache.cxx +++ b/Scenery/tilecache.cxx @@ -88,12 +88,10 @@ int fgTILECACHE::Exists( fgBUCKET *p ) { // Fill in a tile cache entry with real data for the specified bucket void fgTILECACHE::EntryFillIn( int index, fgBUCKET *p ) { - fgOPTIONS *o; + char root[256]; char base_path[256]; char file_name[256]; - o = ¤t_options; - // Mark this cache entry as used tile_cache[index].used = 1; @@ -105,7 +103,8 @@ void fgTILECACHE::EntryFillIn( int index, fgBUCKET *p ) { // Load the appropriate data file and built tile fragment list fgBucketGenBasePath(p, base_path); - sprintf(file_name, "%s/Scenery/%s/%ld", o->fg_root, + current_options.get_fg_root(root); + sprintf(file_name, "%s/Scenery/%s/%ld", root, base_path, fgBucketGenIndex(p)); fgObjLoad(file_name, &tile_cache[index]); /* @@ -213,6 +212,9 @@ fgTILECACHE::~fgTILECACHE( void ) { // $Log$ +// Revision 1.13 1998/07/13 21:02:00 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.12 1998/07/12 03:18:29 curt // Added ground collision detection. This involved: // - saving the entire vertex list for each tile with the tile records. diff --git a/Scenery/tilemgr.cxx b/Scenery/tilemgr.cxx index 252fd83c1..35296384b 100644 --- a/Scenery/tilemgr.cxx +++ b/Scenery/tilemgr.cxx @@ -95,18 +95,19 @@ void fgTileMgrLoadTile( fgBUCKET *p, int *index) { int fgTileMgrUpdate( void ) { fgTILECACHE *c; fgFLIGHT *f; - fgOPTIONS *o; fgBUCKET p1, p2; static fgBUCKET p_last = {-1000, 0, 0, 0}; + int tile_diameter; int i, j, dw, dh; c = &global_tile_cache; f = current_aircraft.flight; - o = ¤t_options; + + tile_diameter = current_options.get_tile_diameter(); fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p1); - dw = o->tile_diameter / 2; - dh = o->tile_diameter / 2; + dw = tile_diameter / 2; + dh = tile_diameter / 2; if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) && (p1.x == p_last.x) && (p1.y == p_last.y) ) { @@ -120,16 +121,16 @@ int fgTileMgrUpdate( void ) { fgPrintf( FG_TERRAIN, FG_INFO, " Updating Tile list for %d,%d %d,%d\n", p1.lon, p1.lat, p1.x, p1.y); fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n", - o->tile_diameter * o->tile_diameter); + tile_diameter * tile_diameter); // wipe/initialize tile cache c->Init(); // build the local area list and update cache - for ( j = 0; j < o->tile_diameter; j++ ) { - for ( i = 0; i < o->tile_diameter; i++ ) { + for ( j = 0; j < tile_diameter; j++ ) { + for ( i = 0; i < tile_diameter; i++ ) { fgBucketOffset(&p1, &p2, i - dw, j - dh); - fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + i]); + fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + i]); } } } else { @@ -146,58 +147,58 @@ int fgTileMgrUpdate( void ) { if ( (p1.lon > p_last.lon) || ( (p1.lon == p_last.lon) && (p1.x > p_last.x) ) ) { fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n", - o->tile_diameter); - for ( j = 0; j < o->tile_diameter; j++ ) { + tile_diameter); + for ( j = 0; j < tile_diameter; j++ ) { // scrolling East - for ( i = 0; i < o->tile_diameter - 1; i++ ) { - tiles[(j*o->tile_diameter) + i] = - tiles[(j*o->tile_diameter) + i + 1]; + for ( i = 0; i < tile_diameter - 1; i++ ) { + tiles[(j*tile_diameter) + i] = + tiles[(j*tile_diameter) + i + 1]; } // load in new column fgBucketOffset(&p_last, &p2, dw + 1, j - dh); - fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + - o->tile_diameter - 1]); + fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + + tile_diameter - 1]); } } else if ( (p1.lon < p_last.lon) || ( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) { fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n", - o->tile_diameter); - for ( j = 0; j < o->tile_diameter; j++ ) { + tile_diameter); + for ( j = 0; j < tile_diameter; j++ ) { // scrolling West - for ( i = o->tile_diameter - 1; i > 0; i-- ) { - tiles[(j*o->tile_diameter) + i] = - tiles[(j*o->tile_diameter) + i - 1]; + for ( i = tile_diameter - 1; i > 0; i-- ) { + tiles[(j*tile_diameter) + i] = + tiles[(j*tile_diameter) + i - 1]; } // load in new column fgBucketOffset(&p_last, &p2, -dw - 1, j - dh); - fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + 0]); + fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + 0]); } } if ( (p1.lat > p_last.lat) || ( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) { fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n", - o->tile_diameter); - for ( i = 0; i < o->tile_diameter; i++ ) { + tile_diameter); + for ( i = 0; i < tile_diameter; i++ ) { // scrolling North - for ( j = 0; j < o->tile_diameter - 1; j++ ) { - tiles[(j * o->tile_diameter) + i] = - tiles[((j+1) * o->tile_diameter) + i]; + for ( j = 0; j < tile_diameter - 1; j++ ) { + tiles[(j * tile_diameter) + i] = + tiles[((j+1) * tile_diameter) + i]; } // load in new column fgBucketOffset(&p_last, &p2, i - dw, dh + 1); - fgTileMgrLoadTile(&p2, &tiles[((o->tile_diameter-1) * - o->tile_diameter) + i]); + fgTileMgrLoadTile(&p2, &tiles[((tile_diameter-1) * + tile_diameter) + i]); } } else if ( (p1.lat < p_last.lat) || ( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) { fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n", - o->tile_diameter); - for ( i = 0; i < o->tile_diameter; i++ ) { + tile_diameter); + for ( i = 0; i < tile_diameter; i++ ) { // scrolling South - for ( j = o->tile_diameter - 1; j > 0; j-- ) { - tiles[(j * o->tile_diameter) + i] = - tiles[((j-1) * o->tile_diameter) + i]; + for ( j = tile_diameter - 1; j > 0; j-- ) { + tiles[(j * tile_diameter) + i] = + tiles[((j-1) * tile_diameter) + i]; } // load in new column fgBucketOffset(&p_last, &p2, i - dw, -dh - 1); @@ -315,7 +316,6 @@ static int viewable( fgPoint3d *cp, double radius ) { void fgTileMgrRender( void ) { fgTILECACHE *c; fgFLIGHT *f; - fgOPTIONS *o; fgTILE *t, *last_tile_ptr; fgVIEW *v; fgBUCKET p; @@ -329,15 +329,18 @@ void fgTileMgrRender( void ) { list < fgFRAGMENT > :: iterator current; list < fgFRAGMENT > :: iterator last; int i, j, size; + int tile_diameter, textures; int index; int culled = 0; int drawn = 0; c = &global_tile_cache; f = current_aircraft.flight; - o = ¤t_options; v = ¤t_view; + tile_diameter = current_options.get_tile_diameter(); + textures = current_options.get_textures(); + // Find current translation offset fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p); index = c->Exists(&p); @@ -362,7 +365,7 @@ void fgTileMgrRender( void ) { // Pass 1 // traverse the potentially viewable tile list - for ( i = 0; i < (o->tile_diameter * o->tile_diameter); i++ ) { + for ( i = 0; i < (tile_diameter * tile_diameter); i++ ) { index = tiles[i]; // fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index); t = c->GetTile(index); @@ -507,7 +510,7 @@ void fgTileMgrRender( void ) { size = mtl_ptr->list_size; if ( size > 0 ) { - if ( o->textures ) { + if ( textures ) { #ifdef GL_VERSION_1_1 xglBindTexture(GL_TEXTURE_2D, mtl_ptr->texture_id); #elif GL_EXT_texture_object @@ -550,6 +553,9 @@ void fgTileMgrRender( void ) { // $Log$ +// Revision 1.25 1998/07/13 21:02:01 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.24 1998/07/12 03:18:29 curt // Added ground collision detection. This involved: // - saving the entire vertex list for each tile with the tile records. diff --git a/Time/event.hxx b/Time/event.hxx index 0f10d78a6..66c1c3738 100644 --- a/Time/event.hxx +++ b/Time/event.hxx @@ -39,6 +39,9 @@ extern "C" void *memset(void *, int, size_t); #include // STL double ended queue #include // STL list +#ifdef NEEDNAMESPACESTD +using namespace std; +#endif #include "fg_time.hxx" @@ -121,6 +124,9 @@ extern fgEVENT_MGR global_events; // $Log$ +// Revision 1.5 1998/07/13 21:02:07 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.4 1998/06/12 00:59:52 curt // Build only static libraries. // Declare memmove/memset for Sloaris. diff --git a/Time/fg_time.cxx b/Time/fg_time.cxx index aa4006624..3de54c3d3 100644 --- a/Time/fg_time.cxx +++ b/Time/fg_time.cxx @@ -63,16 +63,14 @@ fgTIME cur_time_params; // Initialize the time dependent variables void fgTimeInit(fgTIME *t) { - fgOPTIONS *o; - - o = ¤t_options; - fgPrintf( FG_EVENT, FG_INFO, "Initializing Time\n"); t->gst_diff = -9999.0; - fgPrintf( FG_EVENT, FG_DEBUG, "o->time_offset = %d\n", o->time_offset); - t->warp = o->time_offset; + fgPrintf( FG_EVENT, FG_DEBUG, "time offset = %d\n", + current_options.get_time_offset() ); + + t->warp = current_options.get_time_offset(); t->warp_delta = 0; } @@ -409,6 +407,9 @@ void fgTimeUpdate(fgFLIGHT *f, fgTIME *t) { // $Log$ +// Revision 1.10 1998/07/13 21:02:07 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.9 1998/06/12 00:59:53 curt // Build only static libraries. // Declare memmove/memset for Sloaris. diff --git a/Time/light.cxx b/Time/light.cxx index 13c4913c5..92872e7e1 100644 --- a/Time/light.cxx +++ b/Time/light.cxx @@ -59,33 +59,27 @@ fgLIGHT::fgLIGHT( void ) { // initialize lighting tables void fgLIGHT::Init( void ) { - fgOPTIONS *o; char path[256]; fgPrintf( FG_EVENT, FG_INFO, "Initializing Lighting interpolation tables.\n" ); - o = ¤t_options; - // build the path name to the ambient lookup table - path[0] = '\0'; - strcat(path, o->fg_root); + current_options.get_fg_root(path); strcat(path, "/Scenery/"); strcat(path, "Ambient"); // initialize ambient table ambient_tbl = new fgINTERPTABLE(path); // build the path name to the diffuse lookup table - path[0] = '\0'; - strcat(path, o->fg_root); + current_options.get_fg_root(path); strcat(path, "/Scenery/"); strcat(path, "Diffuse"); // initialize diffuse table diffuse_tbl = new fgINTERPTABLE(path); // build the path name to the sky lookup table - path[0] = '\0'; - strcat(path, o->fg_root); + current_options.get_fg_root(path); strcat(path, "/Scenery/"); strcat(path, "Sky"); // initialize sky table @@ -167,6 +161,9 @@ void fgLightUpdate ( void ) { // $Log$ +// Revision 1.11 1998/07/13 21:02:08 curt +// Wrote access functions for current fgOPTIONS. +// // Revision 1.10 1998/07/08 14:48:38 curt // polar3d.h renamed to polar3d.hxx //