mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
// MobileGL - MobileGL/Init.cpp
|
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
|
// Licensed under the GNU Lesser General Public License v3.0:
|
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// End of Source File Header
|
|
|
|
#include "Init.h"
|
|
#include "Config.h"
|
|
#include <MG_Backend/BackendObjects.h>
|
|
#include <MG_State/GLState/Core.h>
|
|
#include <MG_Impl/GLImpl/Texture/ProxyTexture.h>
|
|
#include <MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h>
|
|
|
|
namespace MobileGL {
|
|
void Initialize() {
|
|
MG_Util::Debug::InitFile();
|
|
MGLOG_I("Initializing MobileGL...");
|
|
MG_ConfigLoader::Init();
|
|
MGLOG_I("Config loaded");
|
|
MG_State::Init();
|
|
MGLOG_D("MG_State initialized");
|
|
MG_Backend::Init();
|
|
MGLOG_D("MG_Backend initialized");
|
|
MG_Impl::Init();
|
|
MGLOG_D("MG_Impl initialized");
|
|
glslang::InitializeProcess();
|
|
MGLOG_D("glslang initialized");
|
|
MGLOG_I("MobileGL initialized");
|
|
}
|
|
|
|
void Destroy() {
|
|
MGLOG_I("MobileGL closing...");
|
|
glslang::FinalizeProcess();
|
|
delete MG_State::pGLContext;
|
|
delete MG_Impl::GLImpl::TextureImpl::pProxyTextureManager;
|
|
delete MG_Impl::GLImpl::FramebufferImpl::pDefaultFramebufferInfo;
|
|
MG_Util::Debug::Close();
|
|
|
|
// TODO: add and use Destroy functions for other subsystems
|
|
}
|
|
|
|
#if defined(__linux__) || defined(__APPLE__)
|
|
__attribute__((constructor)) static void AutoInit() {
|
|
Initialize();
|
|
}
|
|
|
|
__attribute__((destructor)) static void AutoDestroy() {
|
|
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:
|
|
Initialize();
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
Destroy();
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
#endif
|
|
} // namespace MobileGL
|