diff --git a/include/osgDB/Registry b/include/osgDB/Registry index 106f3443c..6b93e8ab4 100644 --- a/include/osgDB/Registry +++ b/include/osgDB/Registry @@ -565,6 +565,29 @@ class RegisterReaderWriterProxy osg::ref_ptr _rw; }; +extern "C" +{ + typedef void (* CPluginFunction) (void); +} + +class PluginFunctionProxy +{ +public: + + PluginFunctionProxy(CPluginFunction function) + { + (function)(); + } +}; + +#define USE_OSGPLUGIN(ext) \ + extern "C" void osgdb_##ext(void); \ + static osgDB::PluginFunctionProxy proxy_##ext(osgdb_##ext); + +#define REGISTER_OSGPLUGIN(ext, classname) \ + extern "C" void osgdb_##ext(void) {} \ + static RegisterReaderWriterProxy g_proxy_##classname; + } #endif diff --git a/src/osgPlugins/ive/ReaderWriterIVE.cpp b/src/osgPlugins/ive/ReaderWriterIVE.cpp index bc3b155a3..312c3a00a 100644 --- a/src/osgPlugins/ive/ReaderWriterIVE.cpp +++ b/src/osgPlugins/ive/ReaderWriterIVE.cpp @@ -10,7 +10,7 @@ using namespace osg; using namespace osgDB; -class IVEReaderWriter : public ReaderWriter +class ReaderWriterIVE : public ReaderWriter { public: virtual const char* className() const { return "IVE Reader/Writer"; } @@ -186,4 +186,4 @@ class IVEReaderWriter : public ReaderWriter // now register with Registry to instantiate the above // reader/writer. -RegisterReaderWriterProxy g_IVEReaderWriterProxy; +REGISTER_OSGPLUGIN(ive, ReaderWriterIVE)