#endif
#include <GL/glut.h>
-#include <simgear/xgl/xgl.h>
+#include <GL/gl.h>
#include <simgear/compiler.h>
// build the ssgSimpleState
SGPath tex_path( globals->get_fg_root() );
tex_path.append( "Textures.high" );
-
- SGPath tmp_path = tex_path;
- tmp_path.append( m.get_texture_name() );
- if ( ! local_file_exists(tmp_path.str())
+ tex_path.append( m.get_texture_name() );
+ if ( ! local_file_exists(tex_path.str())
|| general.get_glMaxTexSize() < 512 ) {
tex_path = SGPath( globals->get_fg_root() );
tex_path.append( "Textures" );
+ tex_path.append( m.get_texture_name() );
}
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
shade_model = GL_FLAT;
}
- m.build_ssg_state( tex_path.str(), shade_model,
- fgGetBool("/sim/rendering/textures") );
+ m.set_texture_name( tex_path.str() );
+ m.build_ssg_state( shade_model,
+ fgGetBool("/sim/rendering/textures"),
+ false );
#if EXTRA_DEBUG
m.dump_info();
string tex_name = full_path.substr( pos + 1 );
string tex_path = full_path.substr( 0, pos );
- FGNewMat m( mat_name, tex_name );
+ FGNewMat m( mat_name, full_path );
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
- << mat_name << " (" << tex_path << ")");
+ << mat_name << " (" << full_path << ")");
#if EXTRA_DEBUG
m.dump_info();
shade_model = GL_FLAT;
}
- m.build_ssg_state( tex_path, shade_model,
- fgGetBool("/sim/rendering/textures") );
+ m.build_ssg_state( shade_model, fgGetBool("/sim/rendering/textures"),
+ true );
material_lib.matlib[mat_name] = m;
}
-
-
-
-
-
-
-
-
+// Load one pending "deferred" texture. Return true if a texture
+// loaded successfully, false if no pending, or error.
+void FGMaterialLib::load_next_deferred() {
+ // container::iterator it = begin();
+ for ( material_map_iterator it = begin(); it != end(); it++ ) {
+ const string &key = it->first;
+ FGNewMat &slot = it->second;
+ if ( ! slot.get_texture_loaded() ) {
+ SG_LOG( SG_GENERAL, SG_INFO, "Loading texture for " << key );
+#ifdef PLIB_1_2_X
+ slot.get_textured()->
+ setTexture( (char *)slot.get_texture_name_c_str(), 0, 0 );
+#else
+ slot.get_textured()->
+ setTexture( (char *)slot.get_texture_name_c_str(), 0, 0, 1 );
+#endif
+ slot.set_texture_loaded( true );
+ }
+ }
+}