mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
[Fix] (Init): Refactor MG_Initialize/MG_Destroy for multi-platform compatibility.
This commit is contained in:
@@ -113,6 +113,10 @@
|
||||
|
||||
#include "MG_Include/UncertainBool.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
|
||||
+32
-3
@@ -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
|
||||
Reference in New Issue
Block a user