Browse Source

Platform: make Glfw and Sdl2App work with EGL on desktop GL as well.

A large portion of the needed changes was in the previous commit
already, this does just the remaining part, in particular ensuring EGL
is linked and SDL is told to use EGL as well -- GLFW was told so in the
previous cleanup commit already.
pull/580/head
Vladimír Vondruš 4 years ago
parent
commit
eb89b5cbf9
  1. 2
      doc/changelog.dox
  2. 15
      src/Magnum/Platform/CMakeLists.txt
  3. 4
      src/Magnum/Platform/Sdl2Application.cpp

2
doc/changelog.dox

@ -452,6 +452,8 @@ See also:
- @ref Platform::GlfwApplication now properly uses - @ref Platform::GlfwApplication now properly uses
@ref MAGNUM_TARGET_EGL "EGL" on @ref MAGNUM_TARGET_GLES "GLES builds" (see @ref MAGNUM_TARGET_EGL "EGL" on @ref MAGNUM_TARGET_GLES "GLES builds" (see
[mosra/magnum#470](https://github.com/mosra/magnum/pull/470)) [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 - On Emscripten, @ref Platform::EmscriptenApplication used an internal
allocation function, which changed signature in 2.0.5 and caused runtime 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 failures when `-s ASSERTIONS` was enabled. A public stable API is now used

15
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) if((MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_WEBGL) OR CORRADE_TARGET_IOS)
set(NEED_EGLCONTEXT 1) set(NEED_EGLCONTEXT 1)
set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumEglContextObjects>) set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumEglContextObjects>)
# 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) elseif(CORRADE_TARGET_APPLE)
set(NEED_CGLCONTEXT 1) set(NEED_CGLCONTEXT 1)
set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumCglContextObjects>) set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumCglContextObjects>)
@ -260,12 +261,6 @@ if(MAGNUM_WITH_GLFWAPPLICATION)
${MagnumSomeContext_LIBRARY}) ${MagnumSomeContext_LIBRARY})
endif() 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(FILES ${MagnumGlfwApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumGlfwApplication install(TARGETS MagnumGlfwApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
@ -332,12 +327,6 @@ if(MAGNUM_WITH_SDL2APPLICATION)
${MagnumSomeContext_LIBRARY}) ${MagnumSomeContext_LIBRARY})
endif() 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(FILES ${MagnumSdl2Application_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumSdl2Application install(TARGETS MagnumSdl2Application
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}

4
src/Magnum/Platform/Sdl2Application.cpp

@ -149,6 +149,10 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT):
#ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR #ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
#endif #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) { if(SDL_Init(SDL_INIT_VIDEO) < 0) {
Error() << "Cannot initialize SDL:" << SDL_GetError(); Error() << "Cannot initialize SDL:" << SDL_GetError();

Loading…
Cancel
Save