{
init();
- _internal_state st = { NULL, "", false };
- st.texture_path = texpath;
+ _internal_state st( NULL, texpath, false );
_status.push_back( st );
build_ssg_state( true );
tpath.append("Textures");
tpath.append(tname);
}
- _internal_state st = { NULL, tpath.str(), false };
+ _internal_state st( NULL, tpath.str(), false );
_status.push_back( st );
}
SGPath tpath( fg_root );
tpath.append("Textures");
tpath.append(tname);
- _internal_state st = { NULL, tpath.str(), true };
+ _internal_state st( NULL, tpath.str(), true );
_status.push_back( st );
}
SGMaterial::init ()
{
_status.clear();
+ _current_ptr = 0;
xsize = 0;
ysize = 0;
wrapu = true;
}
ssgSimpleState *
-SGMaterial::get_state (int n) const
+SGMaterial::get_state (int n)
{
- static unsigned current = 0;
-
if (_status.size() == 0) {
SG_LOG( SG_GENERAL, SG_WARN, "No state available.");
return NULL;
}
- if ( ++current >= _status.size())
- current = 0;
+ if ( _current_ptr >= _status.size())
+ _current_ptr = 0;
- return (n >= 0) ? _status[n].state : _status[current].state;
+ return (n >= 0) ? _status[n].state : _status[_current_ptr++].state;
}
void SGMaterial::set_ssg_state( ssgSimpleState *s )
{
- _internal_state st = { s, "", true };
+ _internal_state st( s, "", true );
st.state->ref();
_status.push_back( st );
}
/**
* Get the textured state.
*/
- virtual ssgSimpleState *get_state (int n = -1) const;
+ virtual ssgSimpleState *get_state (int n = -1);
/**
protected:
- typedef struct {
+ struct _internal_state {
+ _internal_state( ssgSimpleState *s, const string &t, bool l )
+ : state(s), texture_path(t), texture_loaded(l) {}
ssgSimpleState *state;
string texture_path;
bool texture_loaded;
- } _internal_state;
+ };
private:
// texture status
vector<_internal_state> _status;
+ // Round-robin counter
+ int _current_ptr;
+
// texture size
double xsize, ysize;