TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ LoadModule()

void ModuleManager::LoadModule ( std::string  path)
private

Definition at line 58 of file ModuleManager.cpp.

59{
60#ifdef TERR3D_WIN32
61 HINSTANCE dll = LoadLibrary(s2ws(path).c_str());
62
63 if(!dll)
64 {
65 std::cout << "Failed to load module: " << path << std::endl;
66 return;
67 }
68
69 GetModuleFunc getModule = (GetModuleFunc)GetProcAddress(dll, "GetModule");
70
71 if(!getModule)
72 {
73 std::cout << "Failed to get module function: " << path << std::endl;
74 FreeLibrary(dll);
75 return;
76 }
77
78 std::string uid = GenerateId(32);
79 Module *module = getModule(uid.data(), appState);
80
81 module->nativeHandle = dll;
82
83#else
84 void *handle;
85 handle = dlopen(path.data(), RTLD_LAZY);
86 if (!handle)
87 {
88 std::cout << "Failed to load module: " << path << std::endl;
89 return;
90 }
91 dlerror();
92 GetModuleFunc getModule = (GetModuleFunc)dlsym(handle, "GetModule");
93 if (!getModule)
94 {
95 std::cout << "Failed to get module function: " << path << std::endl;
96 dlclose(handle);
97 return;
98 }
99
100 std::string uid = GenerateId(32);
101 Module *module = getModule(uid.data(), appState);
102 module->nativeHandle = handle;
103
104#endif
105}
void * nativeHandle
Definition: Module.h:109
Module Info.
Definition: Module.h:40