From 35bf229ed50ee0e2c2b892eda72f1573a9507e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 21 Oct 2019 12:13:15 +0200 Subject: [PATCH] Platform: add Sdl2Application::Configuration::WindowFlag::{OpenGL,Vulkan}. --- doc/changelog.dox | 4 ++++ src/Magnum/Platform/Sdl2Application.cpp | 2 +- src/Magnum/Platform/Sdl2Application.h | 28 +++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 26a439869..d1e2cbf2e 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -298,6 +298,10 @@ See also: in @ref Platform::GlfwApplication and @ref Platform::EmscriptenApplication) for changing window title at runtime as opposed to setting them on application startup +- Added @ref Platform::Sdl2Application::Configuration::WindowFlag::OpenGL and + @ref Platform::Sdl2Application::Configuration::WindowFlag::Vulkan "WindowFlag::Vulkan", + meant to be used together with @ref Platform::Sdl2Application::Configuration::WindowFlag::Contextless for + manual creation of OpenGL contexts and Vulkan instances - @ref Platform::WindowlessEglApplication now uses the @m_class{m-doc-external} [EGL_EXT_device_enumeration](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_device_enumeration.txt), @m_class{m-doc-external} [EGL_EXT_platform_base](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt) and diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index fe028777c..ae90c1cb6 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -295,7 +295,7 @@ bool Sdl2Application::tryCreate(const Configuration& configuration) { #endif SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, scaledWindowSize.x(), scaledWindowSize.y(), - SDL_WINDOW_ALLOW_HIGHDPI|Uint32(configuration.windowFlags() & ~Configuration::WindowFlag::Contextless)))) + SDL_WINDOW_ALLOW_HIGHDPI|SDL_WINDOW_OPENGL|Uint32(configuration.windowFlags() & ~Configuration::WindowFlag::Contextless)))) { Error() << "Platform::Sdl2Application::tryCreate(): cannot create window:" << SDL_GetError(); return false; diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 819ee41f6..12bc0e583 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -1415,7 +1415,28 @@ class Sdl2Application::Configuration { * @ref tryCreate(const Configuration&) to prevent implicit * creation of an OpenGL context. */ - Contextless = 1u << 31 /* Hope this won't ever conflict with anything */ + Contextless = 1u << 31, /* Hope this won't ever conflict with anything */ + + /** + * Request a window for use with OpenGL. Useful in combination with + * @ref WindowFlag::Contextless, otherwise enabled implicitly when + * creating an OpenGL context using @ref Sdl2Application(const Arguments&), + * @ref Sdl2Application(const Arguments, const Configuration&, const GLConfiguration&), + * @ref create(const Configuration&, const GLConfiguration&) or + * @ref tryCreate(const Configuration&, const GLConfiguration&). + */ + OpenGL = SDL_WINDOW_OPENGL, + + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && (SDL_MAJOR_VERSION*1000 + SDL_MINOR_VERSION*100 + SDL_PATCHLEVEL >= 2006 || defined(DOXYGEN_GENERATING_OUTPUT)) + /** + * Request a window for use with Vulkan. Useful in combination with + * @ref WindowFlag::Contextless. + * + * @note Available since SDL 2.0.6, not available on + * @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + */ + Vulkan = SDL_WINDOW_VULKAN + #endif }; /** @@ -1429,7 +1450,10 @@ class Sdl2Application::Configuration { SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS|SDL_WINDOW_HIDDEN| SDL_WINDOW_MAXIMIZED|SDL_WINDOW_MINIMIZED|SDL_WINDOW_INPUT_GRABBED| #endif - Uint32(WindowFlag::Contextless) + Uint32(WindowFlag::Contextless)|SDL_WINDOW_OPENGL + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && SDL_MAJOR_VERSION*1000 + SDL_MINOR_VERSION*100 + SDL_PATCHLEVEL >= 2006 + |SDL_WINDOW_VULKAN + #endif > WindowFlags; #else typedef Containers::EnumSet WindowFlags;