Re-added support for loading on-the-fly textures.
This commit is contained in:
parent
0d999c9936
commit
a01a26a009
4 changed files with 38 additions and 9 deletions
|
@ -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,
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(); }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue