]> git.mxchange.org Git - flightgear.git/commitdiff
Re-added support for loading on-the-fly textures.
authorcurt <curt>
Tue, 15 May 2001 00:01:04 +0000 (00:01 +0000)
committercurt <curt>
Tue, 15 May 2001 00:01:04 +0000 (00:01 +0000)
src/Main/main.cxx
src/Objects/matlib.cxx
src/Objects/matlib.hxx
src/Objects/newmat.hxx

index dacc1abd5d0c233438f53811787d5f7a057fbf5a..685f5db0b90e4143546ee03454a96f66cc07201a 100644 (file)
@@ -81,6 +81,7 @@
 #ifdef FG_NETWORK_OLK
 #include <NetworkOLK/network.h>
 #endif
+#include <Objects/matlib.hxx>
 #include <Scenery/scenery.hxx>
 #include <Scenery/tilemgr.hxx>
 #ifdef ENABLE_AUDIO_SUPPORT
@@ -1035,6 +1036,9 @@ static void fgMainLoop( void ) {
                            cur_fdm_state->get_Latitude()
                             * SGD_RADIANS_TO_DEGREES );
 
+    // see if we need to load any deferred-load textures
+    material_lib.load_next_deferred();
+
     // Process/manage pending events
     global_events.Process();
 
@@ -1525,10 +1529,11 @@ int main( int argc, char **argv ) {
                   0.0 );
     globals->set_ephem( ephem );
 
+    thesky = new SGSky;
+
     SGPath sky_tex_path( globals->get_fg_root() );
     sky_tex_path.append( "Textures" );
     sky_tex_path.append( "Sky" );
-    thesky = new SGSky;
     thesky->texture_path( sky_tex_path.str() );
 
     thesky->build( 550.0, 550.0,
index 60fa40ea5b2205544a423bbfee99cd669adff15f..bfe1b9992ced4332926b3f7e9658344dee7d9379 100644 (file)
@@ -278,11 +278,23 @@ void FGMaterialLib::set_step ( int step )
 }
 
 
-
-
-
-
-
-
-
-
+// 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, 0 );
+#else
+            slot.get_textured()->
+                setTexture( (char *)slot.get_texture_name_c_str(), 0, 0 );
+#endif
+            slot.set_texture_loaded( true );
+        }
+    }
+}
index ad9ef450aa7a0cc443c4a29ad04692a617f3b5b9..5bc7543e0f5706416e1bd8d8b93a12c0b2c93a19 100644 (file)
@@ -87,6 +87,10 @@ public:
 
     void set_step (int step);
 
+    // Load one pending "deferred" texture.  Return true if a texture
+    // loaded successfully, false if no pending, or error.
+    void load_next_deferred();
+
     material_map_iterator begin() { return matlib.begin(); }
     const_material_map_iterator begin() const { return matlib.begin(); }
 
index 39ff8f499dc64fede67f59b5ebba7b1efecea6bf..acd9169bed0bdff875590824db086cbf404914ab 100644 (file)
@@ -113,8 +113,13 @@ public:
     inline void set_material_name( const string& n ) { material_name = n; }
 
     inline string get_texture_name() const { return texture_name; }
+    inline const char *get_texture_name_c_str() const {
+        return texture_name.c_str();
+    }
     inline void set_texture_name( const string& n ) { texture_name = n; }
 
+    inline ssgSimpleState *get_textured() { return textured; }
+
     inline double get_xsize() const { return xsize; }
     inline double get_ysize() const { return ysize; }
     inline void set_xsize( double x ) { xsize = x; }
@@ -129,6 +134,9 @@ public:
     inline void set_specular( sgVec4 s ) { sgCopyVec4( specular, s ); }
     inline void set_emission( sgVec4 e ) { sgCopyVec4( emission, e ); }
 
+    inline bool get_texture_loaded() const { return texture_loaded; }
+    inline void set_texture_loaded( bool val ) { texture_loaded = val; }
+
     inline double get_light_coverage () const { return light_coverage; }
     inline void set_light_coverage (double coverage) {
        light_coverage = coverage;