[Fix] (Init): Refactor MG_Initialize/MG_Destroy for multi-platform compatibility.

This commit is contained in:
BZLZHH
2025-06-05 07:57:07 +08:00
parent aa491bb801
commit 47cd496e6d
2 changed files with 36 additions and 3 deletions
+32 -3
View File
@@ -4,14 +4,43 @@
#include "Includes.h"
__attribute__((constructor)) void MG_Initialize() {
void MG_Initialize() {
MG_Util::Debug::LogInit();
MG_Util::Debug::LogI("MobileGL Initializing...");
MG_State::Init();
MG_GL::BackendLoader::Init();
}
__attribute__((destructor)) void MG_Destroy() {
void MG_Destroy() {
MG_Util::Debug::LogI("MobileGL Exiting...");
MG_State::Destroy();
}
}
#if defined(__linux__) || defined(__APPLE__)
__attribute__((constructor)) static void AutoInit() {
MG_Initialize();
}
__attribute__((destructor)) static void AutoDestroy() {
MG_Destroy();
}
#endif
#ifdef _WIN32
BOOL WINAPI DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
MG_Initialize();
break;
case DLL_PROCESS_DETACH:
MG_Destroy();
break;
}
return TRUE;
}
#endif