From 54de74364180ecffd886543d84161e36f82f0bd7 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 17 Feb 2024 00:51:36 +0100 Subject: [PATCH] Workaround for too old GL header on older SDL versions Problem: Since the removal of !_IRR_OPENGL_USE_EXTPOINTER_ we require some quite recent symbols to compile the legacy GL driver. (*) Since the previous commit we prefer including them via SDL but those are sometimes too old. (*) This was in fact always a problem since USE_EXTPOINTER is the default. I guess people just had recent enough headers usually. --- source/Irrlicht/CMakeLists.txt | 20 +++++++++++++++++++- source/Irrlicht/COpenGLCommon.h | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index 38d03621..52c75537 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -185,7 +185,7 @@ endif() if(ENABLE_OPENGL) add_definitions(-D_IRR_COMPILE_WITH_OPENGL_) - set(OPENGL_DIRECT_LINK TRUE) # not yet possible to remove this + set(OPENGL_DIRECT_LINK TRUE) # driver relies on this if(DEVICE STREQUAL "WINDOWS") add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_) elseif(DEVICE STREQUAL "X11") @@ -269,6 +269,24 @@ if(USE_SDL2) message(STATUS "Found SDL2: ${SDL2_LIBRARIES}") endif() +# More special config + +if(ENABLE_OPENGL AND DEVICE STREQUAL "SDL") + # The legacy GL driver requires some symbols from GL 4.5 to compile, + # which SDL only provides since 2.26.0 (Nov 2022). + # We have a fallback in case this isn't satisfied so test for it. + set(CMAKE_REQUIRED_INCLUDES ${SDL2_INCLUDE_DIRS}) + unset(CHECK_GL_VERSION_4_5 CACHE) + check_cxx_source_compiles("#include \n\ +#ifndef GL_VERSION_4_5\n\ +#error\n\ +#endif\n\ +int main() {}" CHECK_GL_VERSION_4_5) + if(CHECK_GL_VERSION_4_5) + add_definitions(-DIRR_PREFER_SDL_GL_HEADER) + endif() +endif() + # Platform-specific libs if(ANDROID) diff --git a/source/Irrlicht/COpenGLCommon.h b/source/Irrlicht/COpenGLCommon.h index e587130a..17f12f50 100644 --- a/source/Irrlicht/COpenGLCommon.h +++ b/source/Irrlicht/COpenGLCommon.h @@ -6,7 +6,7 @@ #ifdef _IRR_COMPILE_WITH_OPENGL_ -#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && defined(IRR_PREFER_SDL_GL_HEADER) #include #include #else