1
0
Fork 0

Add an option to FGTextureManager to create dynamic textures.

Dynamic textures shouldn't have their STATIC attribute set.
This commit is contained in:
timoore 2007-12-07 09:14:16 +00:00
parent 3426e3cde3
commit 743522fcd1
3 changed files with 7 additions and 5 deletions

View file

@ -118,7 +118,7 @@ fgPanelVisible ()
map<string,osg::ref_ptr<osg::Texture2D> > FGTextureManager::_textureMap; map<string,osg::ref_ptr<osg::Texture2D> > FGTextureManager::_textureMap;
osg::Texture2D* osg::Texture2D*
FGTextureManager::createTexture (const string &relativePath) FGTextureManager::createTexture (const string &relativePath, bool staticTexture)
{ {
osg::Texture2D* texture = _textureMap[relativePath].get(); osg::Texture2D* texture = _textureMap[relativePath].get();
if (texture == 0) { if (texture == 0) {
@ -127,7 +127,7 @@ FGTextureManager::createTexture (const string &relativePath)
SGPath tpath(globals->get_fg_root()); SGPath tpath(globals->get_fg_root());
tpath.append(relativePath); tpath.append(relativePath);
texture = SGLoadTexture2D(tpath); texture = SGLoadTexture2D(staticTexture, tpath);
_textureMap[relativePath] = texture; _textureMap[relativePath] = texture;
if (!_textureMap[relativePath].valid()) if (!_textureMap[relativePath].valid())

View file

@ -75,7 +75,8 @@ class FGPanelInstrument;
class FGTextureManager class FGTextureManager
{ {
public: public:
static osg::Texture2D* createTexture(const string &relativePath); static osg::Texture2D* createTexture(const string &relativePath,
bool staticTexture = true);
static void addTexture(const string &relativePath, osg::Texture2D* texture); static void addTexture(const string &relativePath, osg::Texture2D* texture);
private: private:
static map<string,osg::ref_ptr<osg::Texture2D> > _textureMap; static map<string,osg::ref_ptr<osg::Texture2D> > _textureMap;

View file

@ -112,7 +112,8 @@ wxRadarBg::init ()
// texture name to use in 2D and 3D instruments // texture name to use in 2D and 3D instruments
_texture_path = _Instrument->getStringValue("radar-texture-path", _texture_path = _Instrument->getStringValue("radar-texture-path",
"Aircraft/Instruments/Textures/od_wxradar.rgb"); "Aircraft/Instruments/Textures/od_wxradar.rgb");
_resultTexture = FGTextureManager::createTexture(_texture_path.c_str()); _resultTexture = FGTextureManager::createTexture(_texture_path.c_str(),
false);
SGPath tpath(globals->get_fg_root()); SGPath tpath(globals->get_fg_root());
string path = _Instrument->getStringValue("echo-texture-path", string path = _Instrument->getStringValue("echo-texture-path",
@ -120,7 +121,7 @@ wxRadarBg::init ()
tpath.append(path); tpath.append(path);
// no mipmap or else alpha will mix with pixels on the border of shapes, ruining the effect // no mipmap or else alpha will mix with pixels on the border of shapes, ruining the effect
_wxEcho = SGLoadTexture2D(tpath.c_str(), false, false); _wxEcho = SGLoadTexture2D(tpath, false, false);
_Instrument->setFloatValue("trk", 0.0); _Instrument->setFloatValue("trk", 0.0);