diff --git a/CMakeLists.txt b/CMakeLists.txt index 8065756f..c6eeb991 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,10 @@ find_library(GLSLANG_LIB glslang PATHS ${CMAKE_SOURCE_DIR}/libraries/arm64-v8a/) add_library(${CMAKE_PROJECT_NAME} SHARED MobileGL/Init.cpp - MobileGL/MG_Util/Debug/Log.cpp) + MobileGL/MG_Util/Debug/Log.cpp + + MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp + MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp) target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/library/arm64-v8a/libglslang.a diff --git a/MobileGL/Includes.h b/MobileGL/Includes.h index 480ddd41..0e9c0d91 100644 --- a/MobileGL/Includes.h +++ b/MobileGL/Includes.h @@ -4,6 +4,18 @@ #define __ANDROID_API__ 26 // fix pthread_getname_np not defined #endif +#ifdef _WIN32 +#define MOBILEGL_EXPORT extern "C" __declspec(dllexport) +#else +#define MOBILEGL_EXPORT extern "C" __attribute__((visibility("default"))) +#endif + +#define MOBILEGL_API MOBILEGL_EXPORT + +#define MOBILEGL_GLX_API MOBILEGL_API +#define MOBILEGL_GL_API MOBILEGL_API +#define MOBILEGL_EGL_API MOBILEGL_API + #include #include #include @@ -56,4 +68,5 @@ #include #include "MG_Util/Debug/Log.h" -#include "Config.h" \ No newline at end of file +#include "Config.h" +#include "MG_Impl/GLXImpl/LookUp/LookUp.h" \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp b/MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp new file mode 100644 index 00000000..05411a77 --- /dev/null +++ b/MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp @@ -0,0 +1,9 @@ +#include "../../../Includes.h" + +MOBILEGL_GLX_API void* glXGetProcAddress(const char* name) { + return MG_Impl::GLXImpl::GetProcAddress(name); +} + +MOBILEGL_GLX_API void* glXGetProcAddressARB(const char* name) { + return MG_Impl::GLXImpl::GetProcAddressARB(name); +} \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp new file mode 100644 index 00000000..f309bd51 --- /dev/null +++ b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp @@ -0,0 +1,19 @@ +#include "../../../Includes.h" + +namespace MG_Impl::GLXImpl { + void* GetProcAddress(const char* name) { + MGLOG_D("glXGetProcAddress(\"%s\")", name); + void* proc = dlsym(RTLD_DEFAULT, (const char*)name); + + if (!proc) { + MGLOG_W("Failed to get function: %s", (const char*)name); + return nullptr; + } + + return proc; + } + + void* GetProcAddressARB(const char* name) { + return GetProcAddress(name); + } +} \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.h b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.h new file mode 100644 index 00000000..69979250 --- /dev/null +++ b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.h @@ -0,0 +1,8 @@ +#pragma once + +namespace MG_Impl { + namespace GLXImpl { + void* GetProcAddress(const char* name); + void* GetProcAddressARB(const char* name); + } +} \ No newline at end of file