diff --git a/platforms/sdl/CMakeLists.txt b/platforms/sdl/CMakeLists.txt index 90b720b..4ad5293 100644 --- a/platforms/sdl/CMakeLists.txt +++ b/platforms/sdl/CMakeLists.txt @@ -46,7 +46,6 @@ endif() if(ANDROID) add_library(reminecraftpe SHARED ${SOURCES}) set_target_properties(reminecraftpe PROPERTIES OUTPUT_NAME main) - target_link_libraries(reminecraftpe log) else() add_executable(reminecraftpe ${SOURCES}) endif() diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e7448f5..b474756 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -268,7 +268,6 @@ add_library(reminecraftpe-core STATIC world/tile/DoorTile.cpp renderer/GL/GL.cpp ) - target_include_directories(reminecraftpe-core PUBLIC . ..) # RakNet @@ -289,8 +288,9 @@ else() endif() target_link_libraries(reminecraftpe-core PUBLIC zlib) -# SDL +# Extra Dependencies if(USE_SDL) + # SDL add_library(SDL INTERFACE) if(ANDROID) # Use Vendored SDL2 (Only For Android) @@ -312,7 +312,7 @@ if(USE_SDL) if(NOT EMSCRIPTEN) option(USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE) else() - set(USE_GLES1_COMPATIBILITY_LAYER TRUE) + set(USE_GLES1_COMPATIBILITY_LAYER TRUE CACHE BOOL "" FORCE) endif() if(USE_GLES1_COMPATIBILITY_LAYER) set(GLES_COMPATIBILITY_LAYER_USE_SDL TRUE CACHE BOOL "" FORCE) @@ -323,9 +323,17 @@ if(USE_SDL) if(EMSCRIPTEN) target_link_options(reminecraftpe-core PUBLIC -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2) endif() + else() + find_package(OpenGL REQUIRED) + target_link_libraries(reminecraftpe-core PUBLIC OpenGL::OpenGL) endif() endif() +# Android Logging +if(ANDROID) + target_link_libraries(reminecraftpe-core PUBLIC log) +endif() + # Sound Data if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../sound_data/sounds.h") if(NOT DEFINED ENV{CI}) diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index 9bd2ef8..6ddef71 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -27,6 +27,37 @@ #include + #define USE_GL_ORTHO_F +#else + #ifdef USE_SDL + #define USE_OPENGL_2_FEATURES + + #define GL_GLEXT_PROTOTYPES + #include "thirdparty/SDL2/SDL_opengl.h" + + #ifndef _WIN32 + #include + #endif + #else + #ifdef __APPLE__ + #include + #include + #else + #include + #include + #include // it'll include from a different dir, namely thirdparty/GL/glext.h + #endif + + #ifdef _WIN32 + #pragma comment(lib, "opengl32.lib") + #pragma comment(lib, "glu32.lib") + #endif + #endif + + // use our macro for glOrtho +#endif + +#if defined(USE_GLES) || defined(USE_SDL) // https://cgit.freedesktop.org/mesa/glu/tree/src/libutil/project.c static inline void __gluMakeIdentityf(GLfloat m[16]) { m[0 + 4 * 0] = 1; m[0 + 4 * 1] = 0; m[0 + 4 * 2] = 0; m[0 + 4 * 3] = 0; @@ -55,42 +86,6 @@ m[3][3] = 0; glMultMatrixf(&m[0][0]); } - - #define USE_GL_ORTHO_F - -#else - #include - #include - - #ifdef _WIN32 - #pragma comment(lib, "opengl32.lib") - #pragma comment(lib, "glu32.lib") - #endif - - #ifdef __APPLE__ - #include - #else - #include - #endif - - #ifdef USE_SDL - #define USE_OPENGL_2_FEATURES - - #define GL_GLEXT_PROTOTYPES - #include "thirdparty/SDL2/SDL_opengl.h" - - #ifndef _WIN32 - #include - #endif - - #ifndef __APPLE__ - #include // it'll include from a different dir, namely thirdparty/GL/glext.h - #endif - #elif !defined __APPLE__ - #include // it'll include from a different dir, namely thirdparty/GL/glext.h - #endif - - // use our macro for glOrtho #endif #ifdef USE_OPENGL_2_FEATURES