From 21d053b1b661ac52595bc42a6c767a06c5efeb5e Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 16 Jul 2009 18:25:36 +0200 Subject: [PATCH] Fix effects code to work with OSG 2.8.2-rc4 --- simgear/scene/material/Effect.cxx | 4 +--- simgear/scene/material/makeEffect.cxx | 3 +-- simgear/scene/material/mat.cxx | 21 +++++++++------------ simgear/scene/material/mat.hxx | 16 ++++++---------- simgear/scene/material/matlib.cxx | 7 ++++--- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index ca04ae78..eca35410 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -669,9 +669,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass, if (sitr != shaderMap.end()) { program->addShader(sitr->second.get()); } else { - string fileName = osgDB::Registry::instance() - ->findDataFile(shaderName, options, - osgDB::CASE_SENSITIVE); + string fileName = osgDB::findDataFile(shaderName, options); if (!fileName.empty()) { ref_ptr shader = new Shader(stype); if (shader->loadShaderSourceFromFile(fileName)) { diff --git a/simgear/scene/material/makeEffect.cxx b/simgear/scene/material/makeEffect.cxx index 7745cd97..f437c460 100644 --- a/simgear/scene/material/makeEffect.cxx +++ b/simgear/scene/material/makeEffect.cxx @@ -128,8 +128,7 @@ Effect* makeEffect(const string& name, string effectFileName(name); effectFileName += ".eff"; string absFileName - = osgDB::Registry::instance()->findDataFile(effectFileName, options, - osgDB::CASE_SENSITIVE); + = osgDB::findDataFile(effectFileName, options); if (absFileName.empty()) return 0; SGPropertyNode_ptr effectProps = new SGPropertyNode(); diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 63b8aebd..3a9e9673 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -68,12 +68,12 @@ using namespace simgear; //////////////////////////////////////////////////////////////////////// SGMaterial::_internal_state::_internal_state(Effect *e, const string &t, bool l, - const osgDB::Options* o ) : + const osgDB::ReaderWriter::Options* o ) : effect(e), texture_path(t), effect_realized(l), options(o) { } -SGMaterial::SGMaterial( const osgDB::Options* options, +SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options, const SGPropertyNode *props ) { init(); @@ -91,7 +91,7 @@ SGMaterial::~SGMaterial (void) //////////////////////////////////////////////////////////////////////// void -SGMaterial::read_properties(const osgDB::Options* options, +SGMaterial::read_properties(const osgDB::ReaderWriter::Options* options, const SGPropertyNode *props) { // Gather the path(s) to the texture(s) @@ -104,14 +104,11 @@ SGMaterial::read_properties(const osgDB::Options* options, } SGPath tpath("Textures.high"); tpath.append(tname); - osgDB::Registry* reg = osgDB::Registry::instance(); - string fullTexPath = reg->findDataFile(tpath.str(), options, - osgDB::CASE_SENSITIVE); + string fullTexPath = osgDB::findDataFile(tpath.str(), options); if (fullTexPath.empty()) { tpath = SGPath("Textures"); tpath.append(tname); - fullTexPath = reg->findDataFile(tpath.str(), options, - osgDB::CASE_SENSITIVE); + fullTexPath = osgDB::findDataFile(tpath.str(), options); } if (!fullTexPath.empty() ) { @@ -142,8 +139,7 @@ SGMaterial::read_properties(const osgDB::Options* options, const SGPropertyNode* treeTexNode = props->getChild("tree-texture"); if (treeTexNode) { string treeTexPath = props->getStringValue("tree-texture"); - tree_texture = osgDB::Registry::instance() - ->findDataFile(treeTexPath, options, osgDB::CASE_SENSITIVE); + tree_texture = osgDB::findDataFile(treeTexPath, options); } // surface values for use with ground reactions @@ -246,7 +242,8 @@ Effect* SGMaterial::get_effect(int n) return _status[i].effect.get(); } -void SGMaterial::buildEffectProperties(const osgDB::Options* options) +void SGMaterial::buildEffectProperties(const osgDB::ReaderWriter::Options* + options) { using namespace osg; SGPropertyNode_ptr propRoot = new SGPropertyNode(); diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index ae246ad5..5b74412c 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -39,17 +39,13 @@ #include #include +#include namespace osg { class StateSet; } -namespace osgDB -{ -class Options; -} - #include #include #include @@ -88,7 +84,7 @@ public: * state information for the material. This node is usually * loaded from the $FG_ROOT/materials.xml file. */ - SGMaterial( const osgDB::Options*, const SGPropertyNode *props); + SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props); /** * Destructor. @@ -260,11 +256,11 @@ protected: struct _internal_state { _internal_state(simgear::Effect *e, const std::string &t, bool l, - const osgDB::Options *o); + const osgDB::ReaderWriter::Options *o); osg::ref_ptr effect; std::string texture_path; bool effect_realized; - osg::ref_ptr options; + osg::ref_ptr options; }; private: @@ -344,9 +340,9 @@ private: // Internal constructors and methods. //////////////////////////////////////////////////////////////////// - void read_properties(const osgDB::Options* options, + void read_properties(const osgDB::ReaderWriter::Options* options, const SGPropertyNode *props); - void buildEffectProperties(const osgDB::Options* options); + void buildEffectProperties(const osgDB::ReaderWriter::Options* options); }; diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index c4aa8a8f..6a40426f 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -71,8 +71,9 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, << ex.getMessage() ); throw; } - osg::ref_ptr options = new osgDB::Options; - options->setObjectCacheHint(osgDB::Options::CACHE_ALL); + osg::ref_ptr options + = new osgDB::ReaderWriter::Options; + options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL); options->setDatabasePath(fg_root); int nMaterials = materials.nChildren(); for (int i = 0; i < nMaterials; i++) { -- 2.39.5