From: timoore Date: Fri, 7 Dec 2007 09:13:34 +0000 (+0000) Subject: Add option to SGLoadTexture2D to load dynamic textures X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=037d5c11a5ff9b2fbe6cb94bf454d537c155278b;p=simgear.git Add option to SGLoadTexture2D to load dynamic textures --- diff --git a/simgear/scene/model/model.cxx b/simgear/scene/model/model.cxx index 76d5a90f..becc88c6 100644 --- a/simgear/scene/model/model.cxx +++ b/simgear/scene/model/model.cxx @@ -37,7 +37,7 @@ SG_USING_STD(vector); osg::Texture2D* -SGLoadTexture2D(const std::string& path, +SGLoadTexture2D(bool staticTexture, const std::string& path, const osgDB::ReaderWriter::Options* options, bool wrapu, bool wrapv, int) { @@ -48,7 +48,8 @@ SGLoadTexture2D(const std::string& path, image = osgDB::readImageFile(path); osg::ref_ptr texture = new osg::Texture2D; texture->setImage(image); - texture->setDataVariance(osg::Object::STATIC); + if (staticTexture) + texture->setDataVariance(osg::Object::STATIC); if (wrapu) texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); else diff --git a/simgear/scene/model/model.hxx b/simgear/scene/model/model.hxx index 2f2b01af..db7f6638 100644 --- a/simgear/scene/model/model.hxx +++ b/simgear/scene/model/model.hxx @@ -81,19 +81,37 @@ sgMakeAnimation( osg::Node* model, SGPath &texture_path, set &ignore_branches ); - osg::Texture2D* -SGLoadTexture2D(const std::string& path, +SGLoadTexture2D(bool staticTexture, const std::string& path, const osgDB::ReaderWriter::Options* options = 0, bool wrapu = true, bool wrapv = true, int mipmaplevels = -1); +inline osg::Texture2D* +SGLoadTexture2D(const std::string& path, + const osgDB::ReaderWriter::Options* options = 0, + bool wrapu = true, bool wrapv = true, int mipmaplevels = -1) +{ + return SGLoadTexture2D(true, path, options, wrapu, wrapv, mipmaplevels); +} + inline osg::Texture2D* SGLoadTexture2D(const SGPath& path, const osgDB::ReaderWriter::Options* options = 0, bool wrapu = true, bool wrapv = true, int mipmaplevels = -1) { - return SGLoadTexture2D(path.str(), options, wrapu, wrapv, mipmaplevels); + return SGLoadTexture2D(true, path.str(), options, wrapu, wrapv, + mipmaplevels); +} + +inline osg::Texture2D* +SGLoadTexture2D(bool staticTexture, const SGPath& path, + const osgDB::ReaderWriter::Options* options = 0, + bool wrapu = true, bool wrapv = true, + int mipmaplevels = -1) +{ + return SGLoadTexture2D(staticTexture, path.str(), options, wrapu, wrapv, + mipmaplevels); } #endif // __MODEL_HXX