Introduce C entry point support for plugin setup for better static build support
This commit is contained in:
parent
1676ae839f
commit
8a1ac890f3
@ -565,6 +565,29 @@ class RegisterReaderWriterProxy
|
|||||||
osg::ref_ptr<T> _rw;
|
osg::ref_ptr<T> _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<classname> g_proxy_##classname;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using namespace osg;
|
using namespace osg;
|
||||||
using namespace osgDB;
|
using namespace osgDB;
|
||||||
|
|
||||||
class IVEReaderWriter : public ReaderWriter
|
class ReaderWriterIVE : public ReaderWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual const char* className() const { return "IVE Reader/Writer"; }
|
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
|
// now register with Registry to instantiate the above
|
||||||
// reader/writer.
|
// reader/writer.
|
||||||
RegisterReaderWriterProxy<IVEReaderWriter> g_IVEReaderWriterProxy;
|
REGISTER_OSGPLUGIN(ive, ReaderWriterIVE)
|
||||||
|
Loading…
Reference in New Issue
Block a user