Fix Non-GLES SDL Build

This commit is contained in:
TheBrokenRail
2023-11-03 12:03:50 -04:00
committed by iProgramInCpp
parent 23ec46f266
commit 6e9ccf7b49
3 changed files with 42 additions and 40 deletions

View File

@@ -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()

View File

@@ -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})

67
thirdparty/GL/GL.hpp vendored
View File

@@ -27,6 +27,37 @@
#include <cmath>
#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 <SDL2/SDL_opengl_glext.h>
#endif
#else
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h> // 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 <GL/gl.h>
#include <GL/glu.h>
#ifdef _WIN32
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#endif
#ifdef __APPLE__
#include <OpenGL/glu.h>
#else
#include <GL/glu.h>
#endif
#ifdef USE_SDL
#define USE_OPENGL_2_FEATURES
#define GL_GLEXT_PROTOTYPES
#include "thirdparty/SDL2/SDL_opengl.h"
#ifndef _WIN32
#include <SDL2/SDL_opengl_glext.h>
#endif
#ifndef __APPLE__
#include <GL/glext.h> // it'll include from a different dir, namely thirdparty/GL/glext.h
#endif
#elif !defined __APPLE__
#include <GL/glext.h> // it'll include from a different dir, namely thirdparty/GL/glext.h
#endif
// use our macro for glOrtho
#endif
#ifdef USE_OPENGL_2_FEATURES