]> git.mxchange.org Git - flightgear.git/commitdiff
Tweaked material properties & lighting a bit in GLUTmain.cxx.
authorcurt <curt>
Fri, 29 May 1998 20:37:19 +0000 (20:37 +0000)
committercurt <curt>
Fri, 29 May 1998 20:37:19 +0000 (20:37 +0000)
Read airport list into a "map" STL for dynamic list sizing and fast tree
based lookups.

Main/GLUTmain.cxx
Main/airports.cxx
Main/airports.hxx
Main/fg_init.cxx

index 86b4131f356faa39545eaee3b8e6fdb951a99efc..f0d0c6d310ca573665fabbc8f3f60ef6acfa58e3 100644 (file)
@@ -339,7 +339,6 @@ static void fgRenderFrame( void ) {
     double angle;
     GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
-    GLfloat gray90[4] = { 0.9, 0.9, 0.9, 1.0 };
     GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 };
        
     l = &cur_light_params;
@@ -429,12 +428,14 @@ static void fgRenderFrame( void ) {
        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, gray90);
+       xglMaterialfv (GL_FRONT, GL_AMBIENT, white);
        xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
     } else {
        xglDisable( GL_TEXTURE_2D );
-       xglMaterialfv (GL_FRONT, GL_AMBIENT, terrain_color);
-       xglMaterialfv (GL_FRONT, GL_DIFFUSE, terrain_color);
+       // xglMaterialfv (GL_FRONT, GL_AMBIENT, terrain_color);
+       // xglMaterialfv (GL_FRONT, GL_DIFFUSE, terrain_color);
+       xglMaterialfv (GL_FRONT, GL_AMBIENT, white);
+       xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
     }
 
     fgTileMgrRender();
@@ -778,6 +779,11 @@ extern "C" {
 
 
 // $Log$
+// Revision 1.18  1998/05/29 20:37:19  curt
+// Tweaked material properties & lighting a bit in GLUTmain.cxx.
+// Read airport list into a "map" STL for dynamic list sizing and fast tree
+// based lookups.
+//
 // Revision 1.17  1998/05/22 21:28:52  curt
 // Modifications to use the new fgEVENT_MGR class.
 //
index f6e4aa3436514fb1211a7f39fde9e4405dabff9d..b9222dcfe901bf870a191ae7e012796f8dc585d5 100644 (file)
@@ -41,10 +41,11 @@ 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];
-    double lon, lat, elev;
+    string id_str;
     fgFile f;
 
     o = &current_options;
@@ -65,22 +66,13 @@ int fgAIRPORTS::load( char *file ) {
        }
     }
 
-    size = 0;
     while ( fggets(f, line, 250) != NULL ) {
        // printf("%s", line);
 
-       if ( size < MAX_AIRPORTS ) {
-           sscanf( line, "%s %lf %lf %lfl\n", id, &lon, &lat, &elev );
-           strcpy(airports[size].id, id);
-           airports[size].longitude = lon;
-           airports[size].latitude = lat;
-           airports[size].elevation = elev;
-       } else {
-           fgPrintf( FG_GENERAL, FG_EXIT, 
-                     "Overran size of airport list in fgAIRPORTS::load()\n");
-       }
-
-       size++;
+       sscanf( line, "%s %lf %lf %lfl\n", id, &a.longitude, &a.latitude, 
+               &a.elevation );
+       id_str = id;
+       airports[id_str] = a;
     }
 
     fgclose(f);
@@ -91,16 +83,17 @@ int fgAIRPORTS::load( char *file ) {
 
 // search for the specified id
 fgAIRPORT fgAIRPORTS::search( char *id ) {
+    map < string, fgAIRPORT, less<string> > :: iterator find;
     fgAIRPORT a;
-    int i;
 
-    for ( i = 0; i < size; i++ ) {
-       if ( strcmp(airports[i].id, id) == 0 ) {
-           return(airports[i]);
-       }
+    find = airports.find(id);
+    if ( find == airports.end() ) {
+       // not found
+       a.longitude = a.latitude = a.elevation = 0;
+    } else {
+       a = (*find).second;
     }
 
-    strcpy(a.id, "none");
     return(a);
 }
 
@@ -111,6 +104,11 @@ fgAIRPORTS::~fgAIRPORTS( void ) {
 
 
 // $Log$
+// Revision 1.5  1998/05/29 20:37:22  curt
+// Tweaked material properties & lighting a bit in GLUTmain.cxx.
+// Read airport list into a "map" STL for dynamic list sizing and fast tree
+// based lookups.
+//
 // Revision 1.4  1998/05/13 18:26:25  curt
 // Root path info moved to fgOPTIONS.
 //
index af4ea1eb0cb46d481dab7df68d9f226938a6154b..b4e2686c17380ec6c4690cca05fbec5ba580b4ef 100644 (file)
 #endif                                   
 
 
-#define MAX_AIRPORTS 10000
+#include <map.h>         // STL associative "array"
+
+#if defined(__CYGWIN32__)
+#  include <string>        // Standard C++ string library
+#elif defined(WIN32)
+#  include <string.h>      // Standard C++ string library
+#else
+#  include <std/string.h>  // Standard C++ string library
+#endif
 
 
 typedef struct {
-    char id[5];
+    // char id[5];
     double longitude, latitude, elevation;
 } fgAIRPORT;
 
 
 class fgAIRPORTS {
-    fgAIRPORT airports[MAX_AIRPORTS];
-    int size;
+    map < string, fgAIRPORT, less<string> > airports;
 
 public:
 
@@ -68,6 +75,11 @@ public:
 
 
 // $Log$
+// Revision 1.2  1998/05/29 20:37:22  curt
+// Tweaked material properties & lighting a bit in GLUTmain.cxx.
+// Read airport list into a "map" STL for dynamic list sizing and fast tree
+// based lookups.
+//
 // Revision 1.1  1998/04/25 15:11:11  curt
 // Added an command line option to set starting position based on airport ID.
 //
index 8a7af36bb6d62b8172a1cc532b2ddfa31186f169..8110bedfe842b8bb274c35b1d35b3281776bef46 100644 (file)
@@ -146,7 +146,9 @@ int fgInitPosition( void ) {
 
        airports.load("Airports");
        a = airports.search(o->airport_id);
-       if ( strcmp(a.id, "none") == 0 ) {
+       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);
        } else {
@@ -384,6 +386,11 @@ int fgInitSubsystems( void ) {
 
 
 // $Log$
+// Revision 1.16  1998/05/29 20:37:24  curt
+// Tweaked material properties & lighting a bit in GLUTmain.cxx.
+// Read airport list into a "map" STL for dynamic list sizing and fast tree
+// based lookups.
+//
 // Revision 1.15  1998/05/22 21:28:53  curt
 // Modifications to use the new fgEVENT_MGR class.
 //