From 7352183ad975010cb64f48c429010d0cde0a409c Mon Sep 17 00:00:00 2001
From: curt <curt>
Date: Tue, 28 Apr 1998 01:20:20 +0000
Subject: [PATCH] Type-ified fgTIME and fgVIEW. Added a command line option to
 disable textures.

---
 Main/GLUTkey.cxx  | 14 ++++++++-----
 Main/GLUTmain.cxx | 50 ++++++++++++++++++++++++++++-------------------
 Main/fg_init.cxx  | 14 ++++++++-----
 Main/options.cxx  | 45 +++++++++++++++++++++++++++++++++---------
 Main/options.hxx  |  7 +++++++
 Main/views.cxx    | 10 +++++++---
 Main/views.hxx    | 18 ++++++++++-------
 7 files changed, 109 insertions(+), 49 deletions(-)

diff --git a/Main/GLUTkey.cxx b/Main/GLUTkey.cxx
index d8e3071ef..d8a7e8cd5 100644
--- a/Main/GLUTkey.cxx
+++ b/Main/GLUTkey.cxx
@@ -55,8 +55,8 @@ extern int displayInstruments;
 void GLUTkey(unsigned char k, int x, int y) {
     fgCONTROLS *c;
     fgOPTIONS *o;
-    struct fgTIME *t;
-    struct fgVIEW *v;
+    fgTIME *t;
+    fgVIEW *v;
     struct fgWEATHER *w;
 
     c = current_aircraft.controls;
@@ -186,7 +186,7 @@ void GLUTkey(unsigned char k, int x, int y) {
 /* Handle "special" keyboard events */
 void GLUTspecialkey(int k, int x, int y) {
     fgCONTROLS *c;
-    struct fgVIEW *v;
+    fgVIEW *v;
 
     c = current_aircraft.controls;
     v = &current_view;
@@ -265,9 +265,13 @@ void GLUTspecialkey(int k, int x, int y) {
 
 
 /* $Log$
-/* Revision 1.5  1998/04/25 22:06:29  curt
-/* Edited cvs log messages in source files ... bad bad bad!
+/* Revision 1.6  1998/04/28 01:20:20  curt
+/* 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
  * Cleaned up initialization sequence to eliminate interdependencies
  * between sun position, lighting, and view position.  This creates a
diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx
index 9d49992bb..88cd1191c 100644
--- a/Main/GLUTmain.cxx
+++ b/Main/GLUTmain.cxx
@@ -214,12 +214,10 @@ static void fgInitVisuals( void ) {
 static void fgUpdateViewParams( void ) {
     fgFLIGHT *f;
     fgLIGHT *l;
-    // struct fgTIME *t;
-    struct fgVIEW *v;
+    fgVIEW *v;
 
     f = current_aircraft.flight;
     l = &cur_light_params;
-    // t = &cur_time_params;
     v = &current_view;
 
     fgViewUpdate(f, v, l);
@@ -318,10 +316,11 @@ static void fgUpdateInstrViewParams( void ) {
 static void fgRenderFrame( void ) {
     fgLIGHT *l;
     fgOPTIONS *o;
-    struct fgTIME *t;
-    struct fgVIEW *v;
+    fgTIME *t;
+    fgVIEW *v;
     double angle;
     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;
     o = &current_options;
@@ -384,18 +383,25 @@ static void fgRenderFrame( void ) {
     // set lighting parameters
     xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
     xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
-    // texture parameters
-    xglEnable( GL_TEXTURE_2D ); /* xglDisable( GL_TEXTURE_2D ); */
-    xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ;
-    xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
-    xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ) ;
-    xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
-		      GL_LINEAR /* GL_LINEAR_MIPMAP_LINEAR */ ) ;
-    xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
-    xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ;
-    // set base color (I don't think this is doing anything here)
-    xglMaterialfv (GL_FRONT, GL_AMBIENT, white);
-    xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
+
+    if ( o->use_textures ) {
+	// texture parameters
+	xglEnable( GL_TEXTURE_2D );
+	xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ;
+	xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
+	xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ) ;
+	xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
+			  GL_LINEAR /* GL_LINEAR_MIPMAP_LINEAR */ ) ;
+	xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
+	xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ;
+	// 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();
 
@@ -418,8 +424,8 @@ static void fgRenderFrame( void ) {
 // Update internal time dependent calculations (i.e. flight model)
 void fgUpdateTimeDepCalcs(int multi_loop) {
     fgFLIGHT *f;
-    struct fgTIME *t;
-    struct fgVIEW *v;
+    fgTIME *t;
+    fgVIEW *v;
     int i;
 
     f = current_aircraft.flight;
@@ -484,7 +490,7 @@ static void fgMainLoop( void ) {
     // int joy_b1, joy_b2;
     fgAIRCRAFT *a;
     fgFLIGHT *f;
-    struct fgTIME *t;
+    fgTIME *t;
 
     fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
     fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
@@ -693,6 +699,10 @@ extern "C" {
 
 
 // $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
 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
 //
diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx
index 206cd8210..c08b16b98 100644
--- a/Main/fg_init.cxx
+++ b/Main/fg_init.cxx
@@ -119,9 +119,9 @@ int fgInitPosition( void ) {
     // FG_Altitude = FG_Runway_altitude + 3.758099;
 
     // Test Position
-    // FG_Longitude = ( -109.5 ) * DEG_TO_RAD;
-    // FG_Latitude  = (  32.5 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = (2646 + 2000);
+    // FG_Longitude = ( -110.5 ) * DEG_TO_RAD;
+    // FG_Latitude  = (  34.5 ) * DEG_TO_RAD;
+    // FG_Runway_altitude = (2646 + 6000);
     // FG_Altitude = FG_Runway_altitude + 3.758099;
 
     if ( strlen(o->airport_id) ) {
@@ -190,8 +190,8 @@ int fgInitSubsystems( void ) {
 
     fgFLIGHT *f;
     fgLIGHT *l;
-    struct fgTIME *t;
-    struct fgVIEW *v;
+    fgTIME *t;
+    fgVIEW *v;
 
     l = &cur_light_params;
     t = &cur_time_params;
@@ -369,6 +369,10 @@ int fgInitSubsystems( void ) {
 
 
 // $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
 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
 //
diff --git a/Main/options.cxx b/Main/options.cxx
index fed336b69..724d145f5 100644
--- a/Main/options.cxx
+++ b/Main/options.cxx
@@ -48,6 +48,7 @@ fgOPTIONS::fgOPTIONS( void ) {
     strcpy(airport_id, "");
     hud_status = 0;
     time_offset = 0;
+    use_textures = 1;
 }
 
 
@@ -158,17 +159,22 @@ int fgOPTIONS::parse( int argc, char **argv ) {
     while ( i < argc ) {
 	fgPrintf(FG_GENERAL, FG_INFO, "argv[%d] = %s\n", i, argv[i]);
 
-	if ( strncmp(argv[i], "--airport-id=", 13) == 0 ) {
-	    argv[i] += 13;
-	    strncpy(airport_id, argv[i], 4);
+	// General Options
+	if ( (strcmp(argv[i], "--help") == 0) ||
+	     (strcmp(argv[i], "-h") == 0) ) {
+	    // 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 ( (strcmp(argv[i], "--help") == 0) ||
-	     (strcmp(argv[i], "-h") == 0) ) {
-	    // help/usage request
-	    return(FG_OPTIONS_HELP);
+	} else if ( strncmp(argv[i], "--airport-id=", 13) == 0 ) {
+	    argv[i] += 13;
+	    strncpy(airport_id, argv[i], 4);
+	} 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 ) {
 	    time_offset = parse_time_offset(argv[i]);
 	} else {
@@ -185,10 +191,27 @@ int fgOPTIONS::parse( int argc, char **argv ) {
 // Print usage message
 void fgOPTIONS::usage ( void ) {
     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--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");
 }
 
@@ -199,6 +222,10 @@ fgOPTIONS::~fgOPTIONS( void ) {
 
 
 // $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
 // Added an rint() / HAVE_RINT check.
 //
diff --git a/Main/options.hxx b/Main/options.hxx
index 736d2bcac..afa0a2462 100644
--- a/Main/options.hxx
+++ b/Main/options.hxx
@@ -50,6 +50,9 @@ public:
     // Offset true time by this many seconds
     int time_offset;
 
+    // Textures enabled/disabled
+    int use_textures;
+
     // Constructor
     fgOPTIONS( void );
 
@@ -72,6 +75,10 @@ extern fgOPTIONS current_options;
 
 
 // $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
 // Added an command line option to set starting position based on airport ID.
 //
diff --git a/Main/views.cxx b/Main/views.cxx
index bdaa8d031..a95e202ad 100644
--- a/Main/views.cxx
+++ b/Main/views.cxx
@@ -41,11 +41,11 @@
 
 
 // This is a record containing current view parameters
-struct fgVIEW current_view;
+fgVIEW current_view;
 
 
 // Initialize a view structure
-void fgViewInit(struct fgVIEW *v) {
+void fgViewInit(fgVIEW *v) {
     fgPrintf( FG_VIEW, FG_INFO, "Initializing View parameters\n");
 
     v->view_offset = 0.0;
@@ -54,7 +54,7 @@ void fgViewInit(struct fgVIEW *v) {
 
 
 // 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;
     MAT3mat R, TMP, UP, LOCAL, VIEW;
     double ntmp;
@@ -200,6 +200,10 @@ void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l) {
 
 
 // $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
 // "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
 //
diff --git a/Main/views.hxx b/Main/views.hxx
index dd23ebbc5..1c207772c 100644
--- a/Main/views.hxx
+++ b/Main/views.hxx
@@ -41,7 +41,7 @@
 
 
 /* Define a structure containing view information */
-struct fgVIEW {
+typedef struct {
     /* absolute view position */
     struct fgCartesianPoint abs_view_pos;
 
@@ -81,26 +81,30 @@ struct fgVIEW {
 
     /* the goal view offset for viewing (used for smooth view changes) */
     double goal_view_offset;
-};
+} fgVIEW;
 
 
-extern struct fgVIEW current_view;
+extern fgVIEW current_view;
 
 
 /* Initialize a view structure */
-void fgViewInit(struct fgVIEW *v);
+void fgViewInit(fgVIEW *v);
 
 /* Update the view parameters */
-void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l);
+void fgViewUpdate(fgFLIGHT *f, fgVIEW *v, fgLIGHT *l);
 
 
 #endif /* _VIEWS_HXX */
 
 
 /* $Log$
-/* Revision 1.3  1998/04/25 22:06:31  curt
-/* Edited cvs log messages in source files ... bad bad bad!
+/* Revision 1.4  1998/04/28 01:20:24  curt
+/* 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
  * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
  * Trying out some different option parsing code.