]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/matlib.cxx
A real MSVC fix this time
[simgear.git] / simgear / scene / material / matlib.cxx
index a865ab7ea42b200c000cd256168fec94148a89b0..2165153d584d1c9ba625ab1a191fdd2678ada42f 100644 (file)
 #  include <windows.h>
 #endif
 
-#include GLUT_H
+#include <GL/gl.h>
 
 #include <simgear/compiler.h>
 #include <simgear/constants.h>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
 
 #include <string.h>
 #include STL_STRING
@@ -55,15 +55,12 @@ SG_USING_NAMESPACE(std);
 SG_USING_STD(string);
 
 
-// global material management class
-SGMaterialLib material_lib;
-
-
 // Constructor
 SGMaterialLib::SGMaterialLib ( void ) {
 }
 
 
+#if 0 // debugging infrastructure
 static int gen_test_light_map() {
     static const int env_tex_res = 32;
     int half_res = env_tex_res / 2;
@@ -99,6 +96,7 @@ static int gen_test_light_map() {
 
     return tex_name;
 }
+#endif
 
 
 // generate standard colored directional light environment texture map
@@ -177,10 +175,11 @@ static int gen_taxiway_dir_light_map( int r, int g, int b, int alpha ) {
 
 
 // generate the directional vasi light environment texture map
-static int gen_vasi_light_map() {
+static int gen_vasi_light_map_old() {
     const int env_tex_res = 256;
     int half_res = env_tex_res / 2;
-    unsigned char env_map[env_tex_res][env_tex_res][4];
+
+    static unsigned char env_map[env_tex_res][env_tex_res][4];
     GLuint tex_name;
 
     for ( int i = 0; i < env_tex_res; ++i ) {
@@ -255,7 +254,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
                         << names[j]->getStringValue() );
             }
         } else {
-            SG_LOG(SG_INPUT, SG_ALERT,
+            SG_LOG(SG_INPUT, SG_WARN,
                    "Skipping bad material entry " << node->getName());
         }
     }
@@ -423,7 +422,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
         = new SGMaterial( rwy_red_medium_lights );
 
     // hard coded low intensity runway red light state
-    tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
+    tex_name = gen_standard_dir_light_map( 235, 90, 90, 155 );
     ssgSimpleState *rwy_red_low_lights = new ssgSimpleState();
     rwy_red_low_lights->ref();
     rwy_red_low_lights->disable( GL_LIGHTING );
@@ -477,7 +476,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
         = new SGMaterial( rwy_green_medium_lights );
 
     // hard coded low intensity runway green light state
-    tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
+    tex_name = gen_standard_dir_light_map( 20, 235, 20, 155 );
     ssgSimpleState *rwy_green_low_lights = new ssgSimpleState();
     rwy_green_low_lights->ref();
     rwy_green_low_lights->disable( GL_LIGHTING );
@@ -493,6 +492,8 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
     rwy_green_low_lights->setTexture( tex_name );
     matlib["RWY_GREEN_LOW_LIGHTS"]
         = new SGMaterial( rwy_green_low_lights );
+    matlib["RWY_GREEN_TAXIWAY_LIGHTS"]
+        = new SGMaterial( rwy_green_low_lights );
 
     // hard coded low intensity taxiway blue light state
     tex_name = gen_taxiway_dir_light_map( 90, 90, 235, 205 );
@@ -513,6 +514,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
         = new SGMaterial( taxiway_blue_low_lights );
 
     // hard coded runway vasi light state
+    tex_name = gen_standard_dir_light_map( 235, 235, 195, 255 );
     ssgSimpleState *rwy_vasi_lights = new ssgSimpleState();
     rwy_vasi_lights->ref();
     rwy_vasi_lights->disable( GL_LIGHTING );
@@ -525,7 +527,8 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
     rwy_vasi_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
     rwy_vasi_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
     rwy_vasi_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
-    rwy_vasi_lights->setTexture( gen_vasi_light_map() );
+    // rwy_vasi_lights->setTexture( gen_vasi_light_map_old() );
+    rwy_vasi_lights->setTexture( tex_name );
     matlib["RWY_VASI_LIGHTS"] = new SGMaterial( rwy_vasi_lights );
 
     return true;
@@ -553,7 +556,7 @@ bool SGMaterialLib::add_item ( const string &mat_name, const string &full_path )
     SG_LOG( SG_TERRAIN, SG_INFO, "  Loading material " 
            << mat_name << " (" << full_path << ")");
 
-    material_lib.matlib[mat_name] = new SGMaterial( full_path );
+    matlib[mat_name] = new SGMaterial( full_path );
 
     return true;
 }
@@ -567,7 +570,7 @@ bool SGMaterialLib::add_item ( const string &mat_name, ssgSimpleState *state )
     SG_LOG( SG_TERRAIN, SG_INFO, "  Loading material given a premade "
            << "ssgSimpleState = " << mat_name );
 
-    material_lib.matlib[mat_name] = m;
+    matlib[mat_name] = m;
 
     return true;
 }