From 7103707815cffca95110e65cba3de54e947f6d0f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Feb 2010 10:20:17 +0000 Subject: [PATCH] From Wang Rui, "I also did a small fix to the ObjectWrapper header, to add a OSGDB_EXPORT macro to RegisterCompressorProxy, and modified the findCompressor() method to look for custom compressors in libraries such like osgdb_compressor_name.so, which was described in the wiki page chapter 2.4." --- include/osgDB/ObjectWrapper | 2 +- src/osgDB/ObjectWrapper.cpp | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/include/osgDB/ObjectWrapper b/include/osgDB/ObjectWrapper index 23ccc424e..d93536395 100644 --- a/include/osgDB/ObjectWrapper +++ b/include/osgDB/ObjectWrapper @@ -139,7 +139,7 @@ protected: typedef CLASS MyClass; \ void wrapper_propfunc_##NAME(osgDB::ObjectWrapper* wrapper) -class RegisterCompressorProxy +class OSGDB_EXPORT RegisterCompressorProxy { public: RegisterCompressorProxy( const std::string& name, BaseCompressor* compressor ); diff --git a/src/osgDB/ObjectWrapper.cpp b/src/osgDB/ObjectWrapper.cpp index 102b274e3..c1b06e7d9 100644 --- a/src/osgDB/ObjectWrapper.cpp +++ b/src/osgDB/ObjectWrapper.cpp @@ -490,23 +490,17 @@ BaseCompressor* ObjectWrapperManager::findCompressor( const std::string& name ) if ( itr!=_compressors.end() ) return itr->second.get(); // Load external libraries - std::string::size_type posDoubleColon = name.rfind("::"); - if ( posDoubleColon!=std::string::npos ) - { - std::string libName = std::string( name, 0, posDoubleColon ); + std::string nodeKitLib = osgDB::Registry::instance()->createLibraryNameForNodeKit(name); + if ( osgDB::Registry::instance()->loadLibrary(nodeKitLib)==osgDB::Registry::LOADED ) + return findCompressor(name); - std::string nodeKitLib = osgDB::Registry::instance()->createLibraryNameForNodeKit(libName); - if ( osgDB::Registry::instance()->loadLibrary(nodeKitLib)==osgDB::Registry::LOADED ) - return findCompressor(name); + std::string pluginLib = osgDB::Registry::instance()->createLibraryNameForExtension(std::string("compressor_")+name); + if ( osgDB::Registry::instance()->loadLibrary(pluginLib)==osgDB::Registry::LOADED ) + return findCompressor(name); - std::string pluginLib = osgDB::Registry::instance()->createLibraryNameForExtension(std::string("compressor_")+libName); - if ( osgDB::Registry::instance()->loadLibrary(pluginLib)==osgDB::Registry::LOADED ) - return findCompressor(name); - - pluginLib = osgDB::Registry::instance()->createLibraryNameForExtension(libName); - if ( osgDB::Registry::instance()->loadLibrary(pluginLib)==osgDB::Registry::LOADED ) - return findCompressor(name); - } + pluginLib = osgDB::Registry::instance()->createLibraryNameForExtension(name); + if ( osgDB::Registry::instance()->loadLibrary(pluginLib)==osgDB::Registry::LOADED ) + return findCompressor(name); return NULL; }