diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index bd80d83f1..1e7412964 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -105,6 +105,11 @@ 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()); + #ifndef CORRADE_TARGET_EMSCRIPTEN + /* sRGB */ + SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, configuration.isSRGBCapable()); + #endif + /* Flags: if not hidden, set as shown */ Uint32 windowFlags(configuration.windowFlags()); if(!(configuration.windowFlags() & Configuration::WindowFlag::Hidden)) @@ -413,7 +418,7 @@ Sdl2Application::Configuration::Configuration(): #endif _size(800, 600), _windowFlags{}, _sampleCount(0) #ifndef CORRADE_TARGET_EMSCRIPTEN - , _version(Version::None) + , _version(Version::None), _sRGBCapable{false} #endif {} diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index d2a715542..ffa7e9094 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -719,6 +719,27 @@ class Sdl2Application::Configuration { return *this; } + #ifndef CORRADE_TARGET_EMSCRIPTEN + /** + * @brief sRGB-capable default framebuffer + * + * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + */ + bool isSRGBCapable() const { return _sRGBCapable; } + + /** + * @brief Set sRGB-capable default framebuffer + * @return Reference to self (for method chaining) + * + * Default is `false`. See also @ref Renderer::Feature::FramebufferSRGB. + * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + */ + Configuration& setSRGBCapable(bool enabled) { + _sRGBCapable = enabled; + return *this; + } + #endif + private: #ifndef CORRADE_TARGET_EMSCRIPTEN std::string _title; @@ -729,6 +750,7 @@ class Sdl2Application::Configuration { #ifndef CORRADE_TARGET_EMSCRIPTEN Version _version; Flags _flags; + bool _sRGBCapable; #endif };