From e62b2bb000d46cdd516c6d65d6703019be61ce75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 9 Sep 2022 20:08:24 +0200 Subject: [PATCH] Replace MAGNUM_TARGET_{HEADLESS,DESKTOP_GLES} with MAGNUM_TARGET_EGL. These two options were mutually exclusive, and both were doing the same thing -- switching to EGL on desktop GL, or switching away from EGL on GLES. That made all logic vastly more complicated than it should be, and unfortunately it took me half a decade to realize that. The new logic is significantly simpler everywhere. As usual, the old options are still recognized by CMake on a deprecated build (with a warning), and are still exposed both as CMake variables and a preprocessor define. But the logic for them was quite complicated, so I don't guarantee all cases are covered. I also tried to clean up the dependent CMake options to allow building GLX and WGL apps on GLES independently of whether EGL is used, but it's quite a mess due to the limitations of CMake < 3.22. Build directories that have the options switched randomly over a long time might start misbehaving, but the initial build should work well. --- CMakeLists.txt | 164 ++++++++++++------ doc/building.dox | 16 +- doc/changelog.dox | 15 +- doc/cmake.dox | 10 +- modules/FindMagnum.cmake | 67 +++---- package/archlinux/PKGBUILD-es2desktop | 2 +- package/archlinux/PKGBUILD-es3desktop | 2 +- package/ci/appveyor-desktop-gles.bat | 2 +- src/Magnum/GL/CMakeLists.txt | 6 +- src/Magnum/GL/OpenGL.h | 2 +- src/Magnum/GL/OpenGLTester.h | 14 +- src/Magnum/Magnum.h | 60 ++++--- src/Magnum/Platform/CMakeLists.txt | 49 +++--- src/Magnum/Platform/GlfwApplication.cpp | 10 +- src/Magnum/Platform/GlxApplication.h | 3 +- src/Magnum/Platform/Sdl2Application.cpp | 7 +- .../Platform/WindowlessGlxApplication.h | 5 +- src/Magnum/Platform/gl-info.cpp | 19 +- src/Magnum/Text/CMakeLists.txt | 16 +- src/Magnum/Text/fontconverter.cpp | 10 +- src/Magnum/TextureTools/CMakeLists.txt | 16 +- .../TextureTools/distancefieldconverter.cpp | 12 +- src/Magnum/configure.h.cmake | 26 ++- .../OpenGL/GLES2/CMakeLists.txt | 4 +- .../OpenGL/GLES3/CMakeLists.txt | 4 +- 25 files changed, 292 insertions(+), 249 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb69f5e3e..1c04f11d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,27 +146,17 @@ if(NOT DEFINED _MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS) endforeach() endif() -# If targeting iOS, Android, Emscripten or Windows RT, set explicit OpenGL ES -# support -if(NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT) - option(MAGNUM_TARGET_GLES "Build for OpenGL ES / WebGL" OFF) -else() - set(MAGNUM_TARGET_GLES ON) -endif() - -cmake_dependent_option(MAGNUM_TARGET_GLES2 "Build for OpenGL ES 2 / WebGL 1.0" ON "MAGNUM_TARGET_GLES" OFF) -cmake_dependent_option(MAGNUM_TARGET_DESKTOP_GLES "Build for OpenGL ES on desktop" OFF "MAGNUM_TARGET_GLES" OFF) - # Magnum GL Info (currently only using GLX/CGL/EGL on *nix, WGL/EGL on Windows # and EGL on Emscripten) if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS OR CORRADE_TARGET_EMSCRIPTEN) option(MAGNUM_WITH_GL_INFO "Build magnum-gl-info utility" OFF) endif() -# Desktop-only utilities +# Desktop-only utilities. Not guaranteed to build on GLES, but showing the +# option everywhere for simplicity. if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS) - cmake_dependent_option(MAGNUM_WITH_FONTCONVERTER "Build magnum-fontconverter utility" OFF "NOT MAGNUM_TARGET_GLES" OFF) - cmake_dependent_option(MAGNUM_WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefieldconverter utility" OFF "NOT MAGNUM_TARGET_GLES" OFF) + option(MAGNUM_WITH_FONTCONVERTER "Build magnum-fontconverter utility" OFF) + option(MAGNUM_WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefieldconverter utility" OFF) endif() # API-independent utilities @@ -208,12 +198,31 @@ cmake_dependent_option(MAGNUM_WITH_TRADE "Build Trade library" ON "NOT MAGNUM_WI cmake_dependent_option(MAGNUM_WITH_GL "Build GL library" ON "NOT MAGNUM_WITH_SHADERS;NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_ANDROIDAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSIOSAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSCGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSGLXAPPLICATION;NOT MAGNUM_WITH_CGLCONTEXT;NOT MAGNUM_WITH_GLXAPPLICATION;NOT MAGNUM_WITH_GLXCONTEXT;NOT MAGNUM_WITH_XEGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSWGLAPPLICATION;NOT MAGNUM_WITH_WGLCONTEXT;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON) option(MAGNUM_WITH_PRIMITIVES "Build Primitives library" ON) -cmake_dependent_option(MAGNUM_TARGET_HEADLESS "Build command-line utilities for use on a headless machines" OFF "MAGNUM_WITH_GL" OFF) cmake_dependent_option(MAGNUM_TARGET_GL "Build libraries with OpenGL interoperability" ON "MAGNUM_WITH_GL" OFF) -# EGL context and windowless EGL application, available everywhere -cmake_dependent_option(MAGNUM_WITH_WINDOWLESSEGLAPPLICATION "Build WindowlessEglApplication library" OFF "NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES OR NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_TARGET_HEADLESS" ON) -option(MAGNUM_WITH_EGLCONTEXT "Build EglContext library" OFF) +# If targeting iOS, Android, Emscripten or Windows RT, implicitly enable GLES. +# Otherwise default to desktop GL. +if(CORRADE_TARGET_IOS OR CORRADE_TARGET_ANDROID OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_WINDOWS_RT) + set(MAGNUM_TARGET_GLES ON) +elseif(MAGNUM_WITH_GL) + cmake_dependent_option(MAGNUM_TARGET_GLES "Build for OpenGL ES / WebGL" OFF "MAGNUM_WITH_GL" OFF) +endif() + +# If targeting Android, Emscripten or Windows RT, implicitly enable EGL. +# Otherwise enable EGL by default only if targeting GLES and not on iOS (where +# it's EAGL instead) +if(CORRADE_TARGET_ANDROID OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_WINDOWS_RT) + set(MAGNUM_TARGET_EGL ON) +else() + if(MAGNUM_TARGET_GLES AND NOT CORRADE_TARGET_IOS) + set(_MAGNUM_TARGET_EGL_DEFAULT ON) + else() + set(_MAGNUM_TARGET_EGL_DEFAULT OFF) + endif() + cmake_dependent_option(MAGNUM_TARGET_EGL "Build for EGL instead of EAGL / CGL / GLX / WGL" ${_MAGNUM_TARGET_EGL_DEFAULT} "MAGNUM_WITH_GL" OFF) +endif() + +cmake_dependent_option(MAGNUM_TARGET_GLES2 "Build for OpenGL ES 2 / WebGL 1.0" ON "MAGNUM_TARGET_GLES" OFF) # Vulkan, everywhere except Emscripten if(NOT CORRADE_TARGET_EMSCRIPTEN) @@ -221,6 +230,18 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN) cmake_dependent_option(MAGNUM_TARGET_VK "Build libraries with Vulkan interoperability" ON "MAGNUM_WITH_VK" OFF) endif() +# EGL context and windowless EGL application, available everywhere. If +# targeting EGL and not on Windows, it's implied by the CLI tools, otherwise +# it's independent. +if(MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_WINDOWS) + cmake_dependent_option(MAGNUM_WITH_WINDOWLESSEGLAPPLICATION "Build WindowlessEglApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER;NOT MAGNUM_WITH_FONTCONVERTER" ON) +else() + # TODO when CMake 3.22 can be relied on, clean this up to use a proper + # condition instead + cmake_dependent_option(MAGNUM_WITH_WINDWLESSEGLAPPLICATION "Build WindowlessEglApplication library" OFF "ON" OFF) +endif() +option(MAGNUM_WITH_EGLCONTEXT "Build EglContext library" OFF) + # Android-specific application libraries if(CORRADE_TARGET_ANDROID) option(MAGNUM_WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF) @@ -234,25 +255,42 @@ elseif(CORRADE_TARGET_IOS) option(MAGNUM_WITH_WINDOWLESSIOSAPPLICATION "Build WindowlessIosApplication library" OFF) # macOS-specific application libraries -elseif(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES) - cmake_dependent_option(MAGNUM_WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON) +elseif(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_EGL) + # WindowlessCglApplication implied by the CLI tools unless targeting EGL + if(NOT MAGNUM_TARGET_EGL) + cmake_dependent_option(MAGNUM_WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON) + else() + # TODO when CMake 3.22 can be relied on, clean this up to use a proper + # condition instead + cmake_dependent_option(MAGNUM_WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "ON" OFF) + endif() option(MAGNUM_WITH_CGLCONTEXT "Build CglContext library" OFF) # X11 + GLX/EGL-specific application libraries elseif(CORRADE_TARGET_UNIX) option(MAGNUM_WITH_GLXAPPLICATION "Build GlxApplication library" OFF) - if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) + # WindowlessGlxApplication implied by the CLI tools unless targeting EGL + if(NOT MAGNUM_TARGET_EGL) cmake_dependent_option(MAGNUM_WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON) - option(MAGNUM_WITH_GLXCONTEXT "Build GlxContext library" OFF) + else() + # TODO when CMake 3.22 can be relied on, clean this up to use a proper + # condition instead + cmake_dependent_option(MAGNUM_WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "ON" OFF) endif() + option(MAGNUM_WITH_GLXCONTEXT "Build GlxContext library" OFF) option(MAGNUM_WITH_XEGLAPPLICATION "Build XEglApplication library" OFF) # Windows-specific application libraries elseif(CORRADE_TARGET_WINDOWS) - if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) + # WindowlessWglApplication implied by the CLI tools unless targeting EGL + if(NOT MAGNUM_TARGET_EGL) cmake_dependent_option(MAGNUM_WITH_WINDOWLESSWGLAPPLICATION "Build WindowlessWglApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON) - option(MAGNUM_WITH_WGLCONTEXT "Build WglContext library" OFF) + else() + # TODO when CMake 3.22 can be relied on, clean this up to use a proper + # condition instead + cmake_dependent_option(MAGNUM_WITH_WINDOWLESSWGLAPPLICATION "Build WindowlessWglApplication library" OFF "ON" OFF) endif() + option(MAGNUM_WITH_WGLCONTEXT "Build WglContext library" OFF) endif() # Platform-independent (almost) application libraries @@ -265,18 +303,6 @@ endif() option(MAGNUM_BUILD_DEPRECATED "Include deprecated API in the build" ON) -# BUILD_MULTITHREADED got moved to Corrade itself. In case we're building with -# deprecated features enabled, print a warning in case it's set but Corrade -# reports a different value. We can't print a warning in case it's set because -# that would cause false positives when both Corrade and Magnum are subprojects -# (and thus this option is visible to both). Otherwise it's silent --- for -# non-deprecated builds CMake will at most warn about "variable being unused". -if(MAGNUM_BUILD_DEPRECATED) - if(DEFINED BUILD_MULTITHREADED AND ((NOT CORRADE_BUILD_MULTITHREADED AND BUILD_MULTITHREADED) OR (CORRADE_BUILD_MULTITHREADED AND NOT BUILD_MULTITHREADED))) - message(DEPRECATION "BUILD_MULTITHREADED (set to ${BUILD_MULTITHREADED}) is now ignored — you need to set it when building Corrade instead (there it's ${CORRADE_BUILD_MULTITHREADED} now)") - endif() -endif() - set(MAGNUM_DEPLOY_PREFIX "." CACHE STRING "Prefix where to put final application executables") @@ -386,6 +412,9 @@ if(_MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS AND MAGNUM_BUILD_DEPRECATED) set(WITH_WINDOWLESSCGLAPPLICATION ON) endif() elseif(CORRADE_TARGET_UNIX) + # Checking the old deprecated options here, checking + # MAGNUM_TARGET_EGL wouldn't make sense as that's an option the + # old code definitely won't use. if((NOT TARGET_GLES AND NOT TARGET_HEADLESS) OR TARGET_DESKTOP_GLES) if(NOT DEFINED WITH_WINDOWLESSGLXAPPLICATION) set(WITH_WINDOWLESSGLXAPPLICATION ON) @@ -454,6 +483,45 @@ if(_MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS AND MAGNUM_BUILD_DEPRECATED) endif() endif() +# Handle other deprecated options. For non-deprecated builds CMake will at most +# warn about "variable being unused". Done after the MAGNUM_ prefix backwards +# compatibility above to pick up also the old names, i.e. TARGET_HEADLESS -> +# MAGNUM_TARGET_EGL. +if(MAGNUM_BUILD_DEPRECATED) + # BUILD_MULTITHREADED got moved to Corrade itself. Print a warning in case + # it's set but Corrade reports a different value. We can't print a warning + # in case it's set because that would cause false positives when both + # Corrade and Magnum are subprojects (and thus this option is visible to + # both). + if(DEFINED BUILD_MULTITHREADED AND ((NOT CORRADE_BUILD_MULTITHREADED AND BUILD_MULTITHREADED) OR (CORRADE_BUILD_MULTITHREADED AND NOT BUILD_MULTITHREADED))) + message(DEPRECATION "BUILD_MULTITHREADED (set to ${BUILD_MULTITHREADED}) is now ignored — you need to set it when building Corrade instead (there it's ${CORRADE_BUILD_MULTITHREADED} now)") + endif() + + # The following two options were desktop-only, so don't handle any + # backwards compatibility on mobile / web platforms + if(NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT) + # MAGNUM_TARGET_HEADLESS is now MAGNUM_TARGET_EGL. Print a warning in + # case we're on desktop GL (where it was meant to be used) and the two + # are set to a different value, and sync them. + if(NOT MAGNUM_TARGET_GLES AND DEFINED MAGNUM_TARGET_HEADLESS AND ((NOT MAGNUM_TARGET_EGL AND MAGNUM_TARGET_HEADLESS) OR (MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_HEADLESS))) + message(DEPRECATION "MAGNUM_TARGET_HEADLESS is deprecated, use MAGNUM_TARGET_EGL instead") + set(MAGNUM_TARGET_EGL ${MAGNUM_TARGET_HEADLESS}) + endif() + + # MAGNUM_TARGET_DESKTOP_GLES is now an inverse of MAGNUM_TARGET_EGL. + # Print a warning in case we're on GLES (where it was meant to be used) + # and the two are set to a different value, and sync them. + if(MAGNUM_TARGET_GLES AND DEFINED MAGNUM_TARGET_DESKTOP_GLES AND ((MAGNUM_TARGET_EGL AND MAGNUM_TARGET_DESKTOP_GLES) OR (NOT MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_DESKTOP_GLES))) + message(DEPRECATION "MAGNUM_TARGET_DESKTOP_GLES is deprecated, use MAGNUM_TARGET_EGL instead") + if(MAGNUM_TARGET_DESKTOP_GLES) + set(MAGNUM_TARGET_EGL OFF) + else() + set(MAGNUM_TARGET_EGL ON) + endif() + endif() + endif() +endif() + # Dynamic linking is meaningless on Emscripten and too inconvenient on Android if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) set(MAGNUM_BUILD_STATIC ON) @@ -465,7 +533,7 @@ endif() # Check dependencies if(MAGNUM_WITH_GL) - if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) + if(NOT MAGNUM_TARGET_GLES OR (MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_IOS)) # OpenGL library preference. Prefer to use GLVND, since that's the # better approach nowadays, but allow the users to override it from # outside in case it is broken for some reason (Nvidia drivers in @@ -487,7 +555,7 @@ else() # consistency set(MAGNUM_TARGET_GLES OFF) set(MAGNUM_TARGET_GLES2 OFF) - set(MAGNUM_TARGET_DESKTOP_GLES OFF) + set(MAGNUM_TARGET_EGL OFF) endif() if(NOT MAGNUM_WITH_VK) @@ -523,7 +591,7 @@ if(MAGNUM_BUILD_TESTS) endif() if(MAGNUM_WITH_OPENGLTESTER) - if(MAGNUM_TARGET_HEADLESS OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) + if(MAGNUM_TARGET_EGL) set(MAGNUM_WITH_WINDOWLESSEGLAPPLICATION ON) set(OPENGLTESTER_APPLICATION MagnumWindowlessEglApplication) elseif(CORRADE_TARGET_IOS) @@ -533,21 +601,11 @@ if(MAGNUM_WITH_OPENGLTESTER) set(MAGNUM_WITH_WINDOWLESSCGLAPPLICATION ON) set(OPENGLTESTER_APPLICATION MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - set(MAGNUM_WITH_WINDOWLESSEGLAPPLICATION ON) - set(OPENGLTESTER_APPLICATION MagnumWindowlessEglApplication) - else() - set(MAGNUM_WITH_WINDOWLESSGLXAPPLICATION ON) - set(OPENGLTESTER_APPLICATION MagnumWindowlessGlxApplication) - endif() + set(MAGNUM_WITH_WINDOWLESSGLXAPPLICATION ON) + set(OPENGLTESTER_APPLICATION MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - set(MAGNUM_WITH_WINDOWLESSEGLAPPLICATION ON) - set(OPENGLTESTER_APPLICATION MagnumWindowlessEglApplication) - else() - set(MAGNUM_WITH_WINDOWLESSWGLAPPLICATION ON) - set(OPENGLTESTER_APPLICATION MagnumWindowlessWglApplication) - endif() + set(MAGNUM_WITH_WINDOWLESSWGLAPPLICATION ON) + set(OPENGLTESTER_APPLICATION MagnumWindowlessWglApplication) else() # Assuming this gets hit only if MAGNUM_BUILD_GL_TESTS are enabled message(FATAL_ERROR "Cannot run tests for OpenGL code on this platform. Set MAGNUM_BUILD_GL_TESTS to OFF to skip building them.") diff --git a/doc/building.dox b/doc/building.dox index 8687d4dd6..0ae5caf89 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -461,15 +461,10 @@ available for desktop OpenGL only, see @ref requires-gl. - `MAGNUM_TARGET_GLES2` --- Target OpenGL ES 2.0 instead of 3.0 and later. Available only when `MAGNUM_WITH_GL` is enabled. Currently enabled by default when `MAGNUM_TARGET_GLES` is set. -- `MAGNUM_TARGET_DESKTOP_GLES` --- Target OpenGL ES on desktop, i.e. use - OpenGL ES emulation in desktop OpenGL drivers. Available on Linux and - Windows, though might not be supported by all drivers. Available only when - `MAGNUM_WITH_GL` is enabled. -- `MAGNUM_TARGET_HEADLESS` --- Build command-line utilities for use on a - headless machine. Basically it means that EGL with no display attachment is - being used everywhere instead of platform-specific toolkits like CGL, GLX - or WGL. Supported mainly on OpenGL ES drivers. Available only when - `MAGNUM_WITH_GL` is enabled. +- `MAGNUM_TARGET_EGL` --- Target EGL instead of a platform-specific OpenGL + support library like CGL, EAGL, GLX or WGL. Enabled implicitly on Android, + Emscripten and Windows RT, enabled by default when `MAGNUM_TARGET_GLES` is + set unless on iOS. Available only when `MAGNUM_WITH_GL` is enabled. - `MAGNUM_TARGET_VK` --- Build libraries with Vulkan interoperability enabled. Enabled by default when `MAGNUM_WITH_VK` is enabled. Disabling this will cause libraries to not depend on the @ref Vk library, but doesn't @@ -736,6 +731,9 @@ compatibility if `MAGNUM_BUILD_DEPRECATED` isn't disabled. this was used to handle that case. Nowadays please use NDK r19 and newer, with the unified sysroot layout. Defaults to ``.``. If a relative path is used, it's relative to `CMAKE_INSTALL_PREFIX`. +- `MAGNUM_TARGET_HEADLESS` --- Alias to `MAGNUM_TARGET_EGL`. +- `MAGNUM_TARGET_DESKTOP_GLES` --- Inverse of `MAGNUM_TARGET_EGL` if + `MAGNUM_TARGET_GLES` is enabled. Various plugin interfaces search for plugins in locations and order documented in @ref Corrade::PluginManager::implicitPluginSearchPaths(), diff --git a/doc/changelog.dox b/doc/changelog.dox index 1ca63c0ee..8c654968a 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -449,9 +449,9 @@ See also: - Added a @ref Platform::GlfwApplication::setWindowIcon() overload taking a @ref Corrade::Containers::ArrayView in addition to @ref std::initializer_list -- @ref Platform::GlfwApplication now defaults to EGL on - @ref MAGNUM_TARGET_DESKTOP_GLES "non-desktop" - @ref MAGNUM_TARGET_GLES "GLES builds" (see [mosra/magnum#470](https://github.com/mosra/magnum/pull/470)) +- @ref Platform::GlfwApplication now properly uses + @ref MAGNUM_TARGET_EGL "EGL" on @ref MAGNUM_TARGET_GLES "GLES builds" (see + [mosra/magnum#470](https://github.com/mosra/magnum/pull/470)) - On Emscripten, @ref Platform::EmscriptenApplication used an internal allocation function, which changed signature in 2.0.5 and caused runtime failures when `-s ASSERTIONS` was enabled. A public stable API is now used @@ -768,6 +768,13 @@ See also: @subsection changelog-latest-deprecated Deprecated APIs +- The (mutually exclusive) @ref MAGNUM_TARGET_HEADLESS and + @ref MAGNUM_TARGET_DESKTOP_GLES options, CMake variables and preprocessor + variables are deprecated in favor of @ref MAGNUM_TARGET_EGL. It's enabled + by default on GLES and disabled by default on desktop GL --- disabling it + on GLES will force creation of a GLES context using the GLX / WGL libraries + (if available); enabling it on desktop GL will allow running windowless + applications on headless machines. - All @ref building-features "CMake build options" are now prefixed with `MAGNUM_`. For backwards compatibility, unless @ref MAGNUM_BUILD_DEPRECATED is disabled and unless a prefixed option is already set during the initial @@ -2424,7 +2431,7 @@ Released 2019-10-24, tagged as @ref Platform::Sdl2Application::exitEvent() "exitEvent()" - On OpenGL ES builds, @ref Platform::Sdl2Application now tells SDL whether to use a system GL driver or a dedicated GLES driver based on whether - @ref MAGNUM_TARGET_DESKTOP_GLES is defined. This allows for a smoother + @cpp MAGNUM_TARGET_DESKTOP_GLES @ce is defined. This allows for a smoother experience for example when using ANGLE on Windows. See @ref Platform-Sdl2Application-usage-gles for more information. - Replaced uses of `Pointer_stringify()` in @ref Platform::Sdl2Application diff --git a/doc/cmake.dox b/doc/cmake.dox index 503e9bc66..e6c5b0b38 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -327,11 +327,9 @@ are also available as preprocessor variables if including - `MAGNUM_TARGET_GLES` --- Defined if compiled for OpenGL ES - `MAGNUM_TARGET_GLES2` --- Defined if compiled for OpenGL ES 2.0 - `MAGNUM_TARGET_GLES3` --- Defined if compiled for OpenGL ES 3.0 -- `MAGNUM_TARGET_DESKTOP_GLES` --- Defined if compiled with OpenGL ES - emulation on desktop OpenGL - `MAGNUM_TARGET_WEBGL` --- Defined if compiled for WebGL -- `MAGNUM_TARGET_HEADLESS` --- Defined if compiled for headless machines. See - @ref MAGNUM_TARGET_HEADLESS documentation for more information. +- `MAGNUM_TARGET_EGL` --- Defined if compiled for EGL instead of a + platform-specific OpenGL support library such as CGL, EAGL, GLX or WGL. - `MAGNUM_TARGET_VK` --- Defined if compiled with Vulkan interoperability enabled @@ -341,6 +339,10 @@ release: - `MAGNUM_BUILD_MULTITHREADED` --- Alias to `CORRADE_BUILD_MULTITHREADED`. Use @ref CORRADE_BUILD_MULTITHREADED instead. +- `MAGNUM_TARGET_HEADLESS` --- Alias to `MAGNUM_TARGET_EGL`, unless on iOS, + Android, Emscripten or Windows RT. Use @ref MAGNUM_TARGET_EGL instead. +- `MAGNUM_TARGET_DESKTOP_GLES` --- Defined if compiled for OpenGL ES but + GLX / WGL is used instead of EGL. Use @ref MAGNUM_TARGET_EGL instead. Corrade library provides also its own set of CMake macros and variables, see @ref corrade-cmake "its documentation" for more information. diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 7012edc04..62e10d9a9 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -136,10 +136,9 @@ # MAGNUM_TARGET_GLES - Defined if compiled for OpenGL ES # MAGNUM_TARGET_GLES2 - Defined if compiled for OpenGL ES 2.0 # MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0 -# MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES -# emulation on desktop OpenGL # MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL -# MAGNUM_TARGET_HEADLESS - Defined if compiled for headless machines +# MAGNUM_TARGET_EGL - Defined if compiled for EGL instead of a +# platform-specific OpenGL support library like CGL, EAGL, GLX or WGL # MAGNUM_TARGET_VK - Defined if compiled with Vulkan interop # # The following variables are provided for backwards compatibility purposes @@ -148,6 +147,10 @@ # # MAGNUM_BUILD_MULTITHREADED - Alias to CORRADE_BUILD_MULTITHREADED. Use # CORRADE_BUILD_MULTITHREADED instead. +# MAGNUM_TARGET_HEADLESS - Alias to MAGNUM_TARGET_EGL, unless on iOS, +# Android, Emscripten or Windows RT. Use MAGNUM_TARGET_EGL instead. +# MAGNUM_TARGET_DESKTOP_GLES` - Defined if compiled for OpenGL ES but +# GLX / WGL is used instead of EGL. Use MAGNUM_TARGET_EGL instead. # # Additionally these variables are defined for internal usage: # @@ -268,9 +271,8 @@ set(_magnumFlags TARGET_GLES TARGET_GLES2 TARGET_GLES3 - TARGET_DESKTOP_GLES TARGET_WEBGL - TARGET_HEADLESS + TARGET_EGL TARGET_VK) foreach(_magnumFlag ${_magnumFlags}) list(FIND _magnumConfigure "#define MAGNUM_${_magnumFlag}" _magnum_${_magnumFlag}) @@ -279,9 +281,20 @@ foreach(_magnumFlag ${_magnumFlags}) endif() endforeach() -# For compatibility only, to be removed at some point -if(MAGNUM_BUILD_DEPRECATED AND CORRADE_BUILD_MULTITHREADED) - set(MAGNUM_BUILD_MULTITHREADED 1) +# For compatibility only, to be removed at some point. Refer to +# src/Magnum/configure.h.cmake for the decision logic here. +if(MAGNUM_BUILD_DEPRECATED) + if(CORRADE_BUILD_MULTITHREADED) + set(MAGNUM_BUILD_MULTITHREADED 1) + endif() + if(NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT) + if(NOT MAGNUM_TARGET_GLES AND MAGNUM_TARGET_EGL) + set(MAGNUM_TARGET_HEADLESS 1) + endif() + if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL) + set(MAGNUM_TARGET_DESKTOP_GLES 1) + endif() + endif() endif() # OpenGL library preference. Prefer to use GLVND, since that's the better @@ -425,24 +438,16 @@ if(MAGNUM_TARGET_GL) endif() set(_MAGNUM_OpenGLTester_DEPENDENCIES GL) -if(MAGNUM_TARGET_HEADLESS OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) +if(MAGNUM_TARGET_EGL) list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessEglApplication) elseif(CORRADE_TARGET_IOS) list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessIosApplication) -elseif(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES) +elseif(CORRADE_TARGET_APPLE) list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessCglApplication) elseif(CORRADE_TARGET_UNIX) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessEglApplication) - else() - list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessGlxApplication) - endif() + list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessEglApplication) - else() - list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessWglApplication) - endif() + list(APPEND _MAGNUM_OpenGLTester_DEPENDENCIES WindowlessWglApplication) endif() set(_MAGNUM_Primitives_DEPENDENCIES MeshTools Trade) @@ -706,16 +711,16 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # OPENGL_opengl_LIBRARY because that's set even if # OpenGL_GL_PREFERENCE is explicitly set to LEGACY. if(MAGNUM_TARGET_GL) - if(CORRADE_TARGET_UNIX AND NOT CORRADE_TARGET_APPLE AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) + if(MAGNUM_TARGET_EGL) + find_package(EGL) + set_property(TARGET Magnum::${_component} APPEND + PROPERTY INTERFACE_LINK_LIBRARIES EGL::EGL) + elseif(CORRADE_TARGET_UNIX AND NOT CORRADE_TARGET_APPLE) find_package(OpenGL) if(OPENGL_opengl_LIBRARY AND OpenGL_GL_PREFERENCE STREQUAL GLVND) set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenGL::GLX) endif() - elseif(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES AND NOT CORRADE_TARGET_EMSCRIPTEN) - find_package(EGL) - set_property(TARGET Magnum::${_component} APPEND - PROPERTY INTERFACE_LINK_LIBRARIES EGL::EGL) endif() endif() @@ -745,16 +750,16 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # OPENGL_opengl_LIBRARY because that's set even if # OpenGL_GL_PREFERENCE is explicitly set to LEGACY. if(MAGNUM_TARGET_GL) - if(CORRADE_TARGET_UNIX AND NOT CORRADE_TARGET_APPLE AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) + if(MAGNUM_TARGET_EGL) + find_package(EGL) + set_property(TARGET Magnum::${_component} APPEND + PROPERTY INTERFACE_LINK_LIBRARIES EGL::EGL) + elseif(CORRADE_TARGET_UNIX AND NOT CORRADE_TARGET_APPLE) find_package(OpenGL) if(OPENGL_opengl_LIBRARY AND OpenGL_GL_PREFERENCE STREQUAL GLVND) set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenGL::GLX) endif() - elseif(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES AND NOT CORRADE_TARGET_EMSCRIPTEN) - find_package(EGL) - set_property(TARGET Magnum::${_component} APPEND - PROPERTY INTERFACE_LINK_LIBRARIES EGL::EGL) endif() endif() @@ -852,7 +857,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # GL library elseif(_component STREQUAL GL) - if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) + if(NOT MAGNUM_TARGET_GLES OR (MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_IOS)) # If the GLVND library (CMake 3.11+) was found, link to the # imported target. Otherwise (and also on all systems except # Linux) link to the classic libGL. Can't use diff --git a/package/archlinux/PKGBUILD-es2desktop b/package/archlinux/PKGBUILD-es2desktop index eedadf5f2..a8712d86f 100644 --- a/package/archlinux/PKGBUILD-es2desktop +++ b/package/archlinux/PKGBUILD-es2desktop @@ -22,7 +22,7 @@ build() { -DCMAKE_INSTALL_PREFIX=/usr \ -DMAGNUM_TARGET_GLES=ON \ -DMAGNUM_TARGET_GLES2=ON \ - -DMAGNUM_TARGET_DESKTOP_GLES=ON \ + -DMAGNUM_TARGET_EGL=OFF \ -DMAGNUM_WITH_AUDIO=ON \ -DMAGNUM_WITH_GLFWAPPLICATION=ON \ -DMAGNUM_WITH_GLXAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-es3desktop b/package/archlinux/PKGBUILD-es3desktop index dd24b445a..907ee65a3 100644 --- a/package/archlinux/PKGBUILD-es3desktop +++ b/package/archlinux/PKGBUILD-es3desktop @@ -22,7 +22,7 @@ build() { -DCMAKE_INSTALL_PREFIX=/usr \ -DMAGNUM_TARGET_GLES=ON \ -DMAGNUM_TARGET_GLES2=OFF \ - -DMAGNUM_TARGET_DESKTOP_GLES=ON \ + -DMAGNUM_TARGET_EGL=OFF \ -DMAGNUM_WITH_AUDIO=ON \ -DMAGNUM_WITH_GLFWAPPLICATION=ON \ -DMAGNUM_WITH_GLXAPPLICATION=ON \ diff --git a/package/ci/appveyor-desktop-gles.bat b/package/ci/appveyor-desktop-gles.bat index 31bb5b849..48f0be498 100644 --- a/package/ci/appveyor-desktop-gles.bat +++ b/package/ci/appveyor-desktop-gles.bat @@ -27,7 +27,7 @@ cmake .. ^ -DCMAKE_PREFIX_PATH="%APPVEYOR_BUILD_FOLDER%/openal" ^ -DMAGNUM_TARGET_GLES=ON ^ -DMAGNUM_TARGET_GLES2=%TARGET_GLES2% ^ - -DMAGNUM_TARGET_DESKTOP_GLES=ON ^ + -DMAGNUM_TARGET_EGL=OFF ^ -DMAGNUM_WITH_AUDIO=OFF ^ -DMAGNUM_WITH_VK=OFF ^ -DMAGNUM_WITH_SCENETOOLS=OFF ^ diff --git a/src/Magnum/GL/CMakeLists.txt b/src/Magnum/GL/CMakeLists.txt index 0461c6068..02977172f 100644 --- a/src/Magnum/GL/CMakeLists.txt +++ b/src/Magnum/GL/CMakeLists.txt @@ -214,7 +214,7 @@ elseif(MAGNUM_BUILD_STATIC_PIC) set_target_properties(MagnumGL PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_link_libraries(MagnumGL PUBLIC Magnum) -if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) +if(NOT MAGNUM_TARGET_GLES OR (MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_IOS)) # If the GLVND library (CMake 3.11+) was found, link to the imported # target. Otherwise (and also on all systems except Linux) link to the # classic libGL. Can't use OpenGL_OpenGL_FOUND, because that one is set @@ -297,7 +297,7 @@ if(MAGNUM_BUILD_TESTS) endif() target_link_libraries(MagnumGLTestLib PUBLIC Magnum) - if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) + if(NOT MAGNUM_TARGET_GLES OR (MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_IOS)) # If the GLVND library (CMake 3.11+) was found, link to the imported # target. Otherwise (and also on all systems except Linux) link to the # classic libGL. Can't use OpenGL_OpenGL_FOUND, because that one is set @@ -331,7 +331,7 @@ if(MAGNUM_BUILD_TESTS) # Windows only and elsewhere I just link the same way as with # MagnumOpenGLTester. if(CORRADE_TARGET_WINDOWS) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) + if(MAGNUM_TARGET_EGL) # Otherwise it complains that EGL::EGL does not exist here find_package(EGL) endif() diff --git a/src/Magnum/GL/OpenGL.h b/src/Magnum/GL/OpenGL.h index 9fecc070f..ef206e0cf 100644 --- a/src/Magnum/GL/OpenGL.h +++ b/src/Magnum/GL/OpenGL.h @@ -46,7 +46,7 @@ #endif /* Special case for desktop GLES on Windows (still links to the old opengl32.dll) */ -#elif defined(CORRADE_TARGET_WINDOWS) && defined(MAGNUM_TARGET_DESKTOP_GLES) +#elif defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_EGL) #ifdef MAGNUM_TARGET_GLES2 #include "MagnumExternal/OpenGL/GLES2/flextGLWindowsDesktop.h" #else diff --git a/src/Magnum/GL/OpenGLTester.h b/src/Magnum/GL/OpenGLTester.h index 4606655f7..1ff80c326 100644 --- a/src/Magnum/GL/OpenGLTester.h +++ b/src/Magnum/GL/OpenGLTester.h @@ -37,24 +37,16 @@ #include "Magnum/GL/Renderer.h" #include "Magnum/GL/TimeQuery.h" -#if defined(MAGNUM_TARGET_HEADLESS) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_ANDROID) +#ifdef MAGNUM_TARGET_EGL #include "Magnum/Platform/WindowlessEglApplication.h" #elif defined(CORRADE_TARGET_IOS) #include "Magnum/Platform/WindowlessIosApplication.h" -#elif defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) +#elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessGlxApplication.h" -#endif #elif defined(CORRADE_TARGET_WINDOWS) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessWglApplication.h" -#endif #else #error cannot run OpenGL tests on this platform #endif @@ -98,7 +90,7 @@ See @ref building, @ref cmake and @ref testsuite for more information. Implicitly, running the test executables requires presence of a GPU with OpenGL drivers. In addition, on desktop, unless Magnum is built with -`MAGNUM_TARGET_HEADLESS`, OpenGL context creation requires a graphical desktop +@ref MAGNUM_TARGET_EGL, OpenGL context creation requires a graphical desktop to be running. On embedded systems (and @ref CORRADE_TARGET_IOS "iOS", @ref CORRADE_TARGET_ANDROID "Android" in particular) running the tests has no special requirements. On Emscripten the tests have to be running in a browser, diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 0210090c0..ef8a65ad1 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -131,7 +131,7 @@ Defined if the engine is built with OpenGL interoperability enabled --- extra APIs in various libraries interacting with the @ref Magnum::GL "GL" library. Enabled by default in case the @ref Magnum::GL "GL" library is built. @see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, - @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, @ref cmake + @ref MAGNUM_TARGET_EGL, @ref building, @ref cmake */ #define MAGNUM_TARGET_GL /* (enabled by default) */ @@ -141,7 +141,7 @@ Enabled by default in case the @ref Magnum::GL "GL" library is built. Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0. @see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, - @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, @ref cmake + @ref MAGNUM_TARGET_EGL, @ref building, @ref cmake */ #define MAGNUM_TARGET_GLES #undef MAGNUM_TARGET_GLES @@ -151,7 +151,7 @@ Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0. Defined if the engine is built for OpenGL ES 2.0. Implies also @ref MAGNUM_TARGET_GLES. -@see @ref MAGNUM_TARGET_GLES3, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, +@see @ref MAGNUM_TARGET_GLES3, @ref MAGNUM_TARGET_EGL, @ref building, @ref cmake */ #define MAGNUM_TARGET_GLES2 @@ -162,23 +162,12 @@ Defined if the engine is built for OpenGL ES 2.0. Implies also Defined if the engine is built for OpenGL ES 3.0. Implies also @ref MAGNUM_TARGET_GLES. -@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, +@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_EGL, @ref building, @ref cmake */ #define MAGNUM_TARGET_GLES3 #undef MAGNUM_TARGET_GLES3 -/** -@brief Desktop emulation of OpenGL ES target - -Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0 emulated -within standard desktop OpenGL. Implies also @ref MAGNUM_TARGET_GLES. -@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, @ref building, - @ref cmake -*/ -#define MAGNUM_TARGET_DESKTOP_GLES -#undef MAGNUM_TARGET_DESKTOP_GLES - /** @brief WebGL target @@ -193,19 +182,48 @@ which you might want to be aware of. Implies also @ref MAGNUM_TARGET_GLES and #define MAGNUM_TARGET_WEBGL #undef MAGNUM_TARGET_WEBGL +/** +@brief EGL target +@m_since_latest + +Defined if the engine is built for EGL instead of a platform-specific OpenGL +support library like CGL, EAGL, GLX or WGL. When enabled, +@relativeref{Magnum,Platform::Sdl2Application} and +@relativeref{Magnum,Platform::GlfwApplication} +will create the context using EGL, and command-line utilities like +@ref magnum-gl-info "magnum-gl-info" or +@ref magnum-distancefieldconverter "magnum-distancefieldconverter" as well as +the @relativeref{Magnum,GL::OpenGLTester} library will use +@relativeref{Magnum,Platform::WindowlessEglApplication}. Defined implicitly on +@ref CORRADE_TARGET_IOS "iOS", @ref CORRADE_TARGET_ANDROID "Android", +@ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" and +@ref CORRADE_TARGET_WINDOWS_RT "Windows RT". +*/ +#define MAGNUM_TARGET_EGL +#undef MAGNUM_TARGET_EGL + +#ifdef MAGNUM_BUILD_DEPRECATED /** @brief Headless target +@m_deprecated_since_latest Use @ref MAGNUM_TARGET_EGL instead. -Defined if the engine is built for use on a headless machine (without any -graphical desktop environment). Basically it means that EGL with no display -attachment is being used everywhere instead of platform-specific toolkits like -CGL, GLX or WGL. Note that this might not be supported on all platforms, see -@ref Magnum::Platform::WindowlessEglApplication "Platform::WindowlessEglApplication" -for more information. +Alias to @ref MAGNUM_TARGET_EGL, unless on iOS, Android, Emscripten or Windows +RT. */ #define MAGNUM_TARGET_HEADLESS #undef MAGNUM_TARGET_HEADLESS +/** +@brief OpenGL ES target on GLX / WGL +@m_deprecated_since_latest Use @ref MAGNUM_TARGET_EGL instead. + +Defined if @ref MAGNUM_TARGET_GLES is set but @ref MAGNUM_TARGET_EGL isn't, +unless on iOS, Android, Emscripten or Windows RT. +*/ +#define MAGNUM_TARGET_DESKTOP_GLES +#undef MAGNUM_TARGET_DESKTOP_GLES +#endif + /** @brief Vulkan interoperability diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 3534bfebb..109bf3b6b 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -98,24 +98,29 @@ install(FILES ${MagnumPlatform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR if(MAGNUM_TARGET_GL) # Decide about platform-specific context for cross-platform toolkits if(MAGNUM_WITH_GLFWAPPLICATION OR MAGNUM_WITH_SDL2APPLICATION) - if(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES) + # On WebGL windowless apps don't use anything from EGL, only windowless + # do. On iOS it's EAGL, which isn't really EGL (and thus + # MAGNUM_TARGET_EGL isn't set), but we handle it inside EglContext as + # well. TODO make EaglContext for iOS to prepare for true EGL (such as + # with ANGLE or Zink) + if((MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_WEBGL) OR CORRADE_TARGET_IOS) + set(NEED_EGLCONTEXT 1) + set(MagnumSomeContext_OBJECTS $) + # We're linking to EGL explicitly, no need to bother with GLVND there + elseif(CORRADE_TARGET_APPLE) set(NEED_CGLCONTEXT 1) set(MagnumSomeContext_OBJECTS $) - elseif(CORRADE_TARGET_WINDOWS AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) + elseif(CORRADE_TARGET_WINDOWS) set(NEED_WGLCONTEXT 1) set(MagnumSomeContext_OBJECTS $) - elseif(CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) + elseif(CORRADE_TARGET_UNIX) set(NEED_GLXCONTEXT 1) set(MagnumSomeContext_OBJECTS $) - elseif(MAGNUM_TARGET_GLES AND NOT CORRADE_TARGET_EMSCRIPTEN) - set(NEED_EGLCONTEXT 1) - set(MagnumSomeContext_OBJECTS $) - # We're linking to EGL explicitly, no need to bother with GLVND there endif() endif() # This is needed also by [Windowless]GlxApplication - if((MAGNUM_WITH_GLXAPPLICATION OR MAGNUM_WITH_WINDOWLESSGLXAPPLICATION OR MAGNUM_WITH_GLFWAPPLICATION OR MAGNUM_WITH_SDL2APPLICATION) AND CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) + if((MAGNUM_WITH_GLXAPPLICATION OR MAGNUM_WITH_WINDOWLESSGLXAPPLICATION OR MAGNUM_WITH_GLFWAPPLICATION OR MAGNUM_WITH_SDL2APPLICATION) AND CORRADE_TARGET_UNIX AND NOT MAGNUM_TARGET_EGL) # If the GLVND library (CMake 3.11+) was found and linked to, we need # to link to GLX explicitly. Otherwise (and also on all systems except # Linux) the transitive dependency to classic GL lib from MagnumGL is @@ -255,8 +260,8 @@ if(MAGNUM_WITH_GLFWAPPLICATION) ${MagnumSomeContext_LIBRARY}) endif() - # Link also EGL library, if on ES (and not on WebGL) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES AND NOT MAGNUM_TARGET_WEBGL) + # Link also EGL library, if desired (and not on WebGL) + if(MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_WEBGL) find_package(EGL REQUIRED) target_link_libraries(MagnumGlfwApplication PUBLIC EGL::EGL) endif() @@ -327,8 +332,8 @@ if(MAGNUM_WITH_SDL2APPLICATION) ${MagnumSomeContext_LIBRARY}) endif() - # Link also EGL library, if on ES (and not on WebGL) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES AND NOT MAGNUM_TARGET_WEBGL) + # Link also EGL library, if desired (and not on WebGL) + if(MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_WEBGL) find_package(EGL REQUIRED) target_link_libraries(MagnumSdl2Application PUBLIC EGL::EGL) endif() @@ -731,7 +736,7 @@ endif() if(NOT MAGNUM_TARGET_GLES) list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GL/flextGLPlatform.cpp) elseif(MAGNUM_TARGET_GLES AND MAGNUM_TARGET_GLES2) - if(CORRADE_TARGET_WINDOWS AND MAGNUM_TARGET_DESKTOP_GLES) + if(CORRADE_TARGET_WINDOWS AND NOT MAGNUM_TARGET_EGL) list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES2/flextGLPlatformWindowsDesktop.cpp) elseif(CORRADE_TARGET_IOS) list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp) @@ -739,7 +744,7 @@ elseif(MAGNUM_TARGET_GLES AND MAGNUM_TARGET_GLES2) list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp) endif() elseif(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_GLES2) - if(CORRADE_TARGET_WINDOWS AND MAGNUM_TARGET_DESKTOP_GLES) + if(CORRADE_TARGET_WINDOWS AND NOT MAGNUM_TARGET_EGL) list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES3/flextGLPlatformWindowsDesktop.cpp) elseif(CORRADE_TARGET_IOS) list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp) @@ -903,24 +908,16 @@ if(MAGNUM_WITH_GL_INFO) add_executable(magnum-gl-info gl-info.cpp) target_link_libraries(magnum-gl-info PRIVATE MagnumGL) - if(MAGNUM_TARGET_HEADLESS OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) + if(MAGNUM_TARGET_EGL) target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessEglApplication) elseif(CORRADE_TARGET_IOS) target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessIosApplication) - elseif(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES) + elseif(CORRADE_TARGET_APPLE) target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessEglApplication) - else() - target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessGlxApplication) - endif() + target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessEglApplication) - else() - target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessWglApplication) - endif() + target_link_libraries(magnum-gl-info PRIVATE MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-gl-info is not available on this platform. Set MAGNUM_WITH_GL_INFO to OFF to skip building it.") endif() diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 1852cf8fc..55da5ad12 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -457,10 +457,7 @@ bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConf } #else glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); - /* Force EGL on Windows and non-desktop GLES -- needed by ANGLE: - https://stackoverflow.com/a/58904181/4084782 . Might be useful on - other platforms as well (Mac?), not tested yet. */ - #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_DESKTOP_GLES) + #ifdef MAGNUM_TARGET_EGL /* Force EGL if desired */ glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); #endif #endif @@ -487,10 +484,7 @@ bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConf #endif glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); - /* Force EGL on Windows and non-desktop GLES -- needed by ANGLE: - https://stackoverflow.com/a/58904181/4084782 . Might be useful on - other platforms as well (Mac?), not tested yet. */ - #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_DESKTOP_GLES) + #ifdef MAGNUM_TARGET_EGL /* Force EGL if desired */ glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); #endif #endif diff --git a/src/Magnum/Platform/GlxApplication.h b/src/Magnum/Platform/GlxApplication.h index 7dbdd578c..b9d478557 100644 --- a/src/Magnum/Platform/GlxApplication.h +++ b/src/Magnum/Platform/GlxApplication.h @@ -43,8 +43,7 @@ namespace Magnum { namespace Platform { @m_keywords{Application} Application using pure X11 and GLX. Supports keyboard and mouse handling. -Available on desktop OpenGL and -@ref MAGNUM_TARGET_DESKTOP_GLES "OpenGL ES emulation on desktop" on Linux. +Available on desktop OpenGL and OpenGL ES using GLX on Linux. @section Platform-GlxApplication-bootstrap Bootstrap application diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index f788803dc..c9e6f517e 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -139,10 +139,9 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT): #ifdef SDL_HINT_NO_SIGNAL_HANDLERS SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); #endif - /* Available since 2.0.6, uses dedicated OpenGL ES drivers by default and a - desktop GLES context only if MAGNUM_TARGET_DESKTOP_GLES is defined as - well. */ - #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) && defined(SDL_HINT_OPENGL_ES_DRIVER) + /* Available since 2.0.6, uses dedicated OpenGL ES drivers if EGL is used, + and desktop GLES context otherwise. */ + #if defined(MAGNUM_TARGET_GLES) && defined(MAGNUM_TARGET_EGL) && defined(SDL_HINT_OPENGL_ES_DRIVER) SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1"); #endif /* Available since 2.0.8, disables compositor bypass on X11, which causes diff --git a/src/Magnum/Platform/WindowlessGlxApplication.h b/src/Magnum/Platform/WindowlessGlxApplication.h index a0360a44f..e8ca1c680 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.h +++ b/src/Magnum/Platform/WindowlessGlxApplication.h @@ -344,9 +344,8 @@ CORRADE_ENUMSET_OPERATORS(WindowlessGlxContext::Configuration::Flags) @m_keywords{WindowlessApplication GLX} -Application for offscreen rendering using @ref WindowlessGlxContext. This -application library is available on desktop OpenGL and -@ref MAGNUM_TARGET_DESKTOP_GLES "OpenGL ES emulation on desktop" on Linux. +Application for offscreen rendering using @ref WindowlessGlxContext. Available +on desktop OpenGL and OpenGL ES using GLX on Linux. @section Platform-WindowlessGlxApplication-bootstrap Bootstrap application diff --git a/src/Magnum/Platform/gl-info.cpp b/src/Magnum/Platform/gl-info.cpp index c3705df94..2ded27ad3 100644 --- a/src/Magnum/Platform/gl-info.cpp +++ b/src/Magnum/Platform/gl-info.cpp @@ -58,24 +58,16 @@ #include "Magnum/GL/TransformFeedback.h" #endif -#if defined(MAGNUM_TARGET_HEADLESS) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_ANDROID) +#ifdef MAGNUM_TARGET_EGL #include "Magnum/Platform/WindowlessEglApplication.h" #elif defined(CORRADE_TARGET_IOS) #include "Magnum/Platform/WindowlessIosApplication.h" -#elif defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) +#elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessGlxApplication.h" -#endif #elif defined(CORRADE_TARGET_WINDOWS) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessWglApplication.h" -#endif #else #error no windowless application available on this platform #endif @@ -347,14 +339,11 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifdef MAGNUM_TARGET_GLES2 Debug{} << " MAGNUM_TARGET_GLES2"; #endif - #ifdef MAGNUM_TARGET_DESKTOP_GLES - Debug{} << " MAGNUM_TARGET_DESKTOP_GLES"; - #endif #ifdef MAGNUM_TARGET_WEBGL Debug{} << " MAGNUM_TARGET_WEBGL"; #endif - #ifdef MAGNUM_TARGET_HEADLESS - Debug{} << " MAGNUM_TARGET_HEADLESS"; + #ifdef MAGNUM_TARGET_EGL + Debug{} << " MAGNUM_TARGET_EGL"; #endif Debug{} << "Compiled CPU features:"; Debug{} << " " << Debug::packed << Cpu::compiledFeatures(); diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index d5ac2d0dc..4fd075698 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -117,24 +117,16 @@ if(MAGNUM_WITH_FONTCONVERTER) Magnum MagnumText MagnumTrade) - if(MAGNUM_TARGET_HEADLESS) + if(MAGNUM_TARGET_EGL) target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessEglApplication) elseif(CORRADE_TARGET_IOS) target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessIosApplication) - elseif(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES) + elseif(CORRADE_TARGET_APPLE) target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessEglApplication) - else() - target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessGlxApplication) - endif() + target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessEglApplication) - else() - target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessWglApplication) - endif() + target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-fontconverter is not available on this platform. Set MAGNUM_WITH_FONTCONVERTER to OFF to suppress this warning.") endif() diff --git a/src/Magnum/Text/fontconverter.cpp b/src/Magnum/Text/fontconverter.cpp index 5180df6d4..ab27ed2ba 100644 --- a/src/Magnum/Text/fontconverter.cpp +++ b/src/Magnum/Text/fontconverter.cpp @@ -34,24 +34,16 @@ #include "Magnum/Text/DistanceFieldGlyphCache.h" #include "Magnum/Trade/AbstractImageConverter.h" -#ifdef MAGNUM_TARGET_HEADLESS +#ifdef MAGNUM_TARGET_EGL #include "Magnum/Platform/WindowlessEglApplication.h" #elif defined(CORRADE_TARGET_IOS) #include "Magnum/Platform/WindowlessIosApplication.h" #elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessGlxApplication.h" -#endif #elif defined(CORRADE_TARGET_WINDOWS) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessWglApplication.h" -#endif #else #error no windowless application available on this platform #endif diff --git a/src/Magnum/TextureTools/CMakeLists.txt b/src/Magnum/TextureTools/CMakeLists.txt index 8fc9eafc8..625b71a25 100644 --- a/src/Magnum/TextureTools/CMakeLists.txt +++ b/src/Magnum/TextureTools/CMakeLists.txt @@ -85,24 +85,16 @@ if(MAGNUM_WITH_DISTANCEFIELDCONVERTER) Magnum MagnumTextureTools MagnumTrade) - if(MAGNUM_TARGET_HEADLESS) + if(MAGNUM_TARGET_EGL) target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessEglApplication) elseif(CORRADE_TARGET_IOS) target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessIosApplication) - elseif(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES) + elseif(CORRADE_TARGET_APPLE) target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessEglApplication) - else() - target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessGlxApplication) - endif() + target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) - target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessEglApplication) - else() - target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessWglApplication) - endif() + target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-distancefieldconverter is not available on this platform. Set MAGNUM_WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.") endif() diff --git a/src/Magnum/TextureTools/distancefieldconverter.cpp b/src/Magnum/TextureTools/distancefieldconverter.cpp index 226c01325..8c3d3a181 100644 --- a/src/Magnum/TextureTools/distancefieldconverter.cpp +++ b/src/Magnum/TextureTools/distancefieldconverter.cpp @@ -42,24 +42,16 @@ #include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/ImageData.h" -#ifdef MAGNUM_TARGET_HEADLESS +#ifdef MAGNUM_TARGET_EGL #include "Magnum/Platform/WindowlessEglApplication.h" #elif defined(CORRADE_TARGET_IOS) #include "Magnum/Platform/WindowlessIosApplication.h" -#elif defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) +#elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessGlxApplication.h" -#endif #elif defined(CORRADE_TARGET_WINDOWS) -#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_DESKTOP_GLES) -#include "Magnum/Platform/WindowlessEglApplication.h" -#else #include "Magnum/Platform/WindowlessWglApplication.h" -#endif #else #error no windowless application available on this platform #endif diff --git a/src/Magnum/configure.h.cmake b/src/Magnum/configure.h.cmake index 407bbfd8b..f697971ee 100644 --- a/src/Magnum/configure.h.cmake +++ b/src/Magnum/configure.h.cmake @@ -32,16 +32,34 @@ #cmakedefine MAGNUM_TARGET_GLES #cmakedefine MAGNUM_TARGET_GLES2 #cmakedefine MAGNUM_TARGET_GLES3 -#cmakedefine MAGNUM_TARGET_DESKTOP_GLES #cmakedefine MAGNUM_TARGET_WEBGL -#cmakedefine MAGNUM_TARGET_HEADLESS +#cmakedefine MAGNUM_TARGET_EGL #cmakedefine MAGNUM_TARGET_VK #ifdef MAGNUM_BUILD_DEPRECATED #include "Corrade/configure.h" #ifdef CORRADE_BUILD_MULTITHREADED -/* For compatibility only, to be removed at some point */ -#define MAGNUM_BUILD_MULTITHREADED +/* For compatibility only, to be removed at some point. Deliberate double space + after the #define to avoid being unconditionally matched by older FindMagnum + modules. */ +#define MAGNUM_BUILD_MULTITHREADED +#endif +/* The following applies only to desktop platforms */ +#if !defined(CORRADE_TARGET_IOS) && !defined(CORRADE_TARGET_ANDROID) && !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_WINDOWS_RT) +/* MAGNUM_TARGET_HEADLESS used to be an option defined on desktop GL only, not + on ES; MAGNUM_TARGET_EGL is defined implicitly also on all platforms that + use EGL exclusively. Deliberate double space after the #define to avoid + being unconditionally matched by older FindMagnum modules. */ +#if !defined(MAGNUM_TARGET_GLES) && defined(MAGNUM_TARGET_EGL) +#define MAGNUM_TARGET_HEADLESS +#endif +/* MAGNUM_TARGET_DESKTOP_GLES used to do the opposite of + MAGNUM_TARGET_HEADLESS, i.e. force GLX/WGL instead of EGL on GLES builds. + Deliberate double space after the #define to avoid being unconditionally + matched by older FindMagnum modules. */ +#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_EGL) +#define MAGNUM_TARGET_DESKTOP_GLES +#endif #endif #endif diff --git a/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt b/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt index 843f8aec0..9e6b89b59 100644 --- a/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt @@ -27,9 +27,9 @@ # property that would have to be set on each target separately. set(CMAKE_FOLDER "MagnumExternal/OpenGL") -# Desktop GLES on Windows still links to opengl32.dll so we have a special +# Non-EGL GLES on Windows still links to opengl32.dll so we have a special # function loading code that queries everything above OpenGL 1.1 -if(CORRADE_TARGET_WINDOWS AND MAGNUM_TARGET_DESKTOP_GLES) +if(CORRADE_TARGET_WINDOWS AND NOT MAGNUM_TARGET_EGL) set(MagnumOpenGL_HEADERS flextGLWindowsDesktop.h) set(MagnumOpenGL_SRCS flextGLWindowsDesktop.cpp) diff --git a/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt b/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt index bff885743..96b7023a9 100644 --- a/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt @@ -27,9 +27,9 @@ # property that would have to be set on each target separately. set(CMAKE_FOLDER "MagnumExternal/OpenGL") -# Desktop GLES on Windows still links to opengl32.dll so we have a special +# Non-EGL GLES on Windows still links to opengl32.dll so we have a special # function loading code that queries everything above OpenGL 1.1 -if(CORRADE_TARGET_WINDOWS AND MAGNUM_TARGET_DESKTOP_GLES) +if(CORRADE_TARGET_WINDOWS AND NOT MAGNUM_TARGET_EGL) set(MagnumOpenGL_HEADERS flextGLWindowsDesktop.h) set(MagnumOpenGL_SRCS flextGLWindowsDesktop.cpp)