From d7d65db884d4daba728c92cbfb2d6e5c884b425d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 15 Feb 2019 16:00:38 +0100 Subject: [PATCH] Platform: hint SDL what GLES library we want to use. --- doc/changelog.dox | 8 ++++++++ src/Magnum/Platform/Sdl2Application.cpp | 6 ++++++ src/Magnum/Platform/Sdl2Application.h | 11 +++++++++++ 3 files changed, 25 insertions(+) diff --git a/doc/changelog.dox b/doc/changelog.dox index dca6bff8a..ba1b9164a 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -46,6 +46,14 @@ See also: recognizes also uppercase file extensions (see [mosra/magnum#312](https://github.com/mosra/magnum/pull/312)) +@subsubsection changelog-latest-changes-platform Platform libraries + +- 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 + experience for example when using ANGLE on Windows. See + @ref Platform-Sdl2Application-usage-gles for more information. + @subsubsection changelog-latest-changes-trade Trade library - The @ref Trade::AnyImageImporter "AnyImageImporter", diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 46ade2d00..71289ebb1 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -97,6 +97,12 @@ 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_DESKTOP_GLES) && 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 flickering on KWin as the compositor gets shut down on every startup */ #ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 1a50b1c72..613b9a190 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -305,6 +305,17 @@ If you enable @ref Configuration::WindowFlag::Resizable, the canvas will be resized when size of the canvas changes and you get @ref viewportEvent(). If the flag is not enabled, no canvas resizing is performed. +@subsection Platform-Sdl2Application-usage-gles OpenGL ES specifics + +For OpenGL ES, SDL2 defaults to a "desktop GLES" context of the system driver. +Because Magnum has the opposite default behavior, if @ref MAGNUM_TARGET_GLES is +not defined and SDL >= 2.0.6 is used, @ref Sdl2Application sets the +`SDL_HINT_OPENGL_ES_DRIVER` hint to 1, forcing it to load symbols from a +dedicated libGLES library instead, making SDL and Magnum consistently use the +same OpenGL entrypoints. This change also allows @ref platforms-gl-es-angle "ANGLE" +to be used on Windows simply by placing the corresponding `libEGL.dll` and +`libGLESv2.dll` files next to the application executable. + @section Platform-Sdl2Application-dpi DPI awareness On displays that match the platform default DPI (96 or 72),