diff --git a/doc/changelog.dox b/doc/changelog.dox index 8c654968a..d596ee711 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -452,6 +452,8 @@ See also: - @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)) +- @ref Platform::GlfwApplication and @ref Platform::Sdl2Application can now + work with EGL on desktop GL as well if @ref MAGNUM_TARGET_EGL is enabled - 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 diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 109bf3b6b..fbe01944b 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -106,7 +106,8 @@ if(MAGNUM_TARGET_GL) 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 + find_package(EGL REQUIRED) + set(MagnumSomeContext_LIBRARY EGL::EGL) elseif(CORRADE_TARGET_APPLE) set(NEED_CGLCONTEXT 1) set(MagnumSomeContext_OBJECTS $) @@ -260,12 +261,6 @@ if(MAGNUM_WITH_GLFWAPPLICATION) ${MagnumSomeContext_LIBRARY}) endif() - # 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() - install(FILES ${MagnumGlfwApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumGlfwApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} @@ -332,12 +327,6 @@ if(MAGNUM_WITH_SDL2APPLICATION) ${MagnumSomeContext_LIBRARY}) endif() - # 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() - install(FILES ${MagnumSdl2Application_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumSdl2Application RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index c9e6f517e..9888fb6a7 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -149,6 +149,10 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT): #ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); #endif + /* Available since 2.0.12, use EGL if MAGNUM_TARGET_HEADLESS is enabled */ + #if defined(MAGNUM_TARGET_HEADLESS) && defined(SDL_HINT_VIDEO_X11_FORCE_EGL) + SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1"); + #endif if(SDL_Init(SDL_INIT_VIDEO) < 0) { Error() << "Cannot initialize SDL:" << SDL_GetError();