diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index cf44a5e6a..f74fd887e 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -103,7 +103,7 @@ class MAGNUM_EXPORT Context { /** * @brief Context flag * - * @see @ref Flags, @ref flags() + * @see @ref Flags, @ref flags(), @ref Platform::Sdl2Application::Configuration::setFlags() "Platform::*Application::Configuration::setFlags()" */ enum class Flag: GLint { /** diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 2735cfcbf..0a2c86728 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -109,6 +109,9 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, configuration.sampleCount() > 1 ? 1 : 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configuration.sampleCount()); + /* Context flags */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, int(configuration.flags())); + /* Flags: if not hidden, set as shown */ Uint32 windowFlags(configuration.windowFlags()); if(!(configuration.windowFlags() & Configuration::WindowFlag::Hidden)) windowFlags |= SDL_WINDOW_SHOWN; diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index e4dd18f64..222e0e1f0 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -423,6 +423,30 @@ depth buffer. */ class Sdl2Application::Configuration { public: + /** + * @brief Context flag + * + * @see @ref Flags @ref setFlags() + */ + enum class Flag: int { + Debug = SDL_GL_CONTEXT_DEBUG_FLAG, /**< Create debug context */ + + /** Create context with robust access */ + RobustAccess = SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG + }; + + /** + * @brief Context flags + * + * @see @ref setFlags() + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + typedef Containers::EnumSet Flags; + #else + typedef Containers::EnumSet Flags; + #endif + /** * @brief Window flag * @@ -508,6 +532,20 @@ class Sdl2Application::Configuration { return *this; } + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + #ifndef CORRADE_TARGET_EMSCRIPTEN /** * @brief Context version @@ -561,8 +599,10 @@ class Sdl2Application::Configuration { #ifndef CORRADE_TARGET_EMSCRIPTEN Version _version; #endif + Flags _flags; }; +CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::Flags) CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::WindowFlags) /**