fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / CSMPlugin / SimpleTest / simplePluginApp.cpp
blob43985adbfc7ef943c817a1e71c30053150620dd7
2 #ifdef WIN32
3 #else
4 #include <dlfcn.h>
5 #endif
7 #include <stdio.h>
9 #include "OSGSimpleCSMPluginInterface.h"
11 #ifdef WIN32
12 void doit(int argc, char **argv)
14 HMODULE pHandle =
15 LoadLibrary("bin/ReleaseNoOpt/OSGContribCSMSimplePluginRN.dll");
17 if(pHandle != NULL)
19 OSG::CreateInterfaceF pInitF =
20 reinterpret_cast<OSG::CreateInterfaceF>(
21 GetProcAddress(pHandle, "createInterface"));
23 if(pInitF != NULL)
25 OSG::SimpleCSMPluginInterface *pIf = (pInitF)();
27 if(pIf != NULL)
29 pIf->run(argc, argv);
31 delete pIf;
33 FreeLibrary(pHandle);
35 else
37 fprintf(stderr, "could not get interface\n");
40 else
42 fprintf(stderr, "could not get init func\n");
45 else
47 fprintf(stderr, "Could not open plugin so\n");
50 #else
51 void doit(int argc, char **argv)
53 void *pHandle = dlopen("bin/libOSGContribCSMSimplePlugin.so",
54 (RTLD_LAZY | RTLD_GLOBAL));
56 if(pHandle != NULL)
58 OSG::CreateInterfaceF pInitF =
59 reinterpret_cast<OSG::CreateInterfaceF>(
60 dlsym(pHandle, "createInterface"));
62 if(pInitF != NULL)
64 OSG::SimpleCSMPluginInterface *pIf = (pInitF)();
66 if(pIf != NULL)
68 pIf->run(argc, argv);
70 delete pIf;
72 dlclose(pHandle);
74 else
76 fprintf(stderr, "could not get interface\n");
79 else
81 fprintf(stderr, "could not get init func\n");
84 else
86 fprintf(stderr, "Could not open plugin so\n");
89 #endif
91 int main(int argc, char **argv)
93 for(int i = 0; i < 5; ++i)
94 doit(argc, argv);
96 return 0;