From 1c66807e101280d6129e74c087b365b50597a550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Feb 2021 11:43:48 +0100 Subject: [PATCH] Platform: explicitly override Configuration::Flags in all apps. These will become a subset of what GL::Context::Configuration::Flag provides and so can't just inherit the enum anymore. --- src/Magnum/Platform/AbstractXApplication.h | 89 ++++++++++++++++--- src/Magnum/Platform/AndroidApplication.h | 89 ++++++++++++++++--- .../Platform/WindowlessCglApplication.h | 89 ++++++++++++++++--- .../Platform/WindowlessIosApplication.h | 76 ++++++++++++++-- 4 files changed, 301 insertions(+), 42 deletions(-) diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index e5e60c322..fc91893a4 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -340,32 +340,97 @@ Double-buffered OpenGL context. */ class AbstractXApplication::GLConfiguration: public GL::Context::Configuration { public: + /** + * @brief Context flag + * + * Includes also everything from @ref GL::Context::Configuration::Flag. + * @see @ref Flags, @ref setFlags(), @ref GL::Context::Flag + */ + enum class Flag: UnsignedLong { + /** + * @copydoc GL::Context::Configuration::Flag::QuietLog + * @m_since_latest + */ + QuietLog = UnsignedLong(GL::Context::Configuration::Flag::QuietLog), + + /** + * @copydoc GL::Context::Configuration::Flag::VerboseLog + * @m_since_latest + */ + VerboseLog = UnsignedLong(GL::Context::Configuration::Flag::VerboseLog), + + /** + * @copydoc GL::Context::Configuration::Flag::GpuValidation + * @m_since_latest + */ + GpuValidation = UnsignedLong(GL::Context::Configuration::Flag::GpuValidation) + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + typedef Containers::EnumSet Flags; + explicit GLConfiguration(); ~GLConfiguration(); - /** @copydoc Sdl2Application::GLConfiguration::version() */ - GL::Version version() const { return _version; } - - /** @copydoc Sdl2Application::GLConfiguration::setVersion() */ - GLConfiguration& setVersion(GL::Version version) { - _version = version; - return *this; + /** @brief Context flags */ + Flags flags() const { + return Flag(UnsignedLong(GL::Context::Configuration::flags())); } - /* Overloads to remove WTF-factor from method chaining order */ - #ifndef DOXYGEN_GENERATING_OUTPUT + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. To avoid clearing default flags by accident, + * prefer to use @ref addFlags() and @ref clearFlags() instead. + * @see @ref GL::Context::flags() + */ GLConfiguration& setFlags(Flags flags) { - GL::Context::Configuration::setFlags(flags); + GL::Context::Configuration::setFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); return *this; } + + /** + * @brief Add context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ORs the flags with existing instead of + * replacing them. Useful for preserving the defaults. + * @see @ref clearFlags() + */ GLConfiguration& addFlags(Flags flags) { - GL::Context::Configuration::addFlags(flags); + GL::Context::Configuration::addFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); return *this; } + + /** + * @brief Clear context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ANDs the inverse of @p flags with existing + * instead of replacing them. Useful for removing default flags. + * @see @ref addFlags() + */ GLConfiguration& clearFlags(Flags flags) { - GL::Context::Configuration::clearFlags(flags); + GL::Context::Configuration::clearFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); + return *this; + } + + /** @copydoc Sdl2Application::GLConfiguration::version() */ + GL::Version version() const { return _version; } + + /** @copydoc Sdl2Application::GLConfiguration::setVersion() */ + GLConfiguration& setVersion(GL::Version version) { + _version = version; return *this; } + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT MAGNUM_GL_CONTEXT_CONFIGURATION_SUBCLASS_IMPLEMENTATION(GLConfiguration) #endif diff --git a/src/Magnum/Platform/AndroidApplication.h b/src/Magnum/Platform/AndroidApplication.h index 6d00d55c0..d6055afad 100644 --- a/src/Magnum/Platform/AndroidApplication.h +++ b/src/Magnum/Platform/AndroidApplication.h @@ -453,8 +453,85 @@ Double-buffered RGBA canvas with depth and stencil buffers. */ class AndroidApplication::GLConfiguration: public GL::Context::Configuration { public: + /** + * @brief Context flag + * + * Includes also everything from @ref GL::Context::Configuration::Flag. + * @see @ref Flags, @ref setFlags(), @ref GL::Context::Flag + */ + enum class Flag: UnsignedLong { + /** + * @copydoc GL::Context::Configuration::Flag::QuietLog + * @m_since_latest + */ + QuietLog = UnsignedLong(GL::Context::Configuration::Flag::QuietLog), + + /** + * @copydoc GL::Context::Configuration::Flag::VerboseLog + * @m_since_latest + */ + VerboseLog = UnsignedLong(GL::Context::Configuration::Flag::VerboseLog), + + /** + * @copydoc GL::Context::Configuration::Flag::GpuValidation + * @m_since_latest + */ + GpuValidation = UnsignedLong(GL::Context::Configuration::Flag::GpuValidation) + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + typedef Containers::EnumSet Flags; + /*implicit*/ GLConfiguration(); + /** @brief Context flags */ + Flags flags() const { + return Flag(UnsignedLong(GL::Context::Configuration::flags())); + } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. To avoid clearing default flags by accident, + * prefer to use @ref addFlags() and @ref clearFlags() instead. + * @see @ref GL::Context::flags() + */ + GLConfiguration& setFlags(Flags flags) { + GL::Context::Configuration::setFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); + return *this; + } + + /** + * @brief Add context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ORs the flags with existing instead of + * replacing them. Useful for preserving the defaults. + * @see @ref clearFlags() + */ + GLConfiguration& addFlags(Flags flags) { + GL::Context::Configuration::addFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); + return *this; + } + + /** + * @brief Clear context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ANDs the inverse of @p flags with existing + * instead of replacing them. Useful for removing default flags. + * @see @ref addFlags() + */ + GLConfiguration& clearFlags(Flags flags) { + GL::Context::Configuration::clearFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); + return *this; + } + /** * @brief Set context version * @@ -509,18 +586,6 @@ class AndroidApplication::GLConfiguration: public GL::Context::Configuration { /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - GLConfiguration& setFlags(Flags flags) { - GL::Context::Configuration::setFlags(flags); - return *this; - } - GLConfiguration& addFlags(Flags flags) { - GL::Context::Configuration::addFlags(flags); - return *this; - } - GLConfiguration& clearFlags(Flags flags) { - GL::Context::Configuration::clearFlags(flags); - return *this; - } MAGNUM_GL_CONTEXT_CONFIGURATION_SUBCLASS_IMPLEMENTATION(GLConfiguration) #endif diff --git a/src/Magnum/Platform/WindowlessCglApplication.h b/src/Magnum/Platform/WindowlessCglApplication.h index a8f58a46d..20f8d8fda 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.h +++ b/src/Magnum/Platform/WindowlessCglApplication.h @@ -163,6 +163,83 @@ class WindowlessCglContext { */ class WindowlessCglContext::Configuration: public GL::Context::Configuration { public: + /** + * @brief Context flag + * + * Includes also everything from @ref GL::Context::Configuration::Flag. + * @see @ref Flags, @ref setFlags(), @ref GL::Context::Flag + */ + enum class Flag: UnsignedLong { + /** + * @copydoc GL::Context::Configuration::Flag::QuietLog + * @m_since_latest + */ + QuietLog = UnsignedLong(GL::Context::Configuration::Flag::QuietLog), + + /** + * @copydoc GL::Context::Configuration::Flag::VerboseLog + * @m_since_latest + */ + VerboseLog = UnsignedLong(GL::Context::Configuration::Flag::VerboseLog), + + /** + * @copydoc GL::Context::Configuration::Flag::GpuValidation + * @m_since_latest + */ + GpuValidation = UnsignedLong(GL::Context::Configuration::Flag::GpuValidation) + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + typedef Containers::EnumSet Flags; + + /** @brief Context flags */ + Flags flags() const { + return Flag(UnsignedLong(GL::Context::Configuration::flags())); + } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. To avoid clearing default flags by accident, + * prefer to use @ref addFlags() and @ref clearFlags() instead. + * @see @ref GL::Context::flags() + */ + Configuration& setFlags(Flags flags) { + GL::Context::Configuration::setFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); + return *this; + } + + /** + * @brief Add context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ORs the flags with existing instead of + * replacing them. Useful for preserving the defaults. + * @see @ref clearFlags() + */ + Configuration& addFlags(Flags flags) { + GL::Context::Configuration::addFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); + return *this; + } + + /** + * @brief Clear context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ANDs the inverse of @p flags with existing + * instead of replacing them. Useful for removing default flags. + * @see @ref addFlags() + */ + Configuration& clearFlags(Flags flags) { + GL::Context::Configuration::clearFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); + return *this; + } + /** * @brief Create a shared context * @return Reference to self (for method chaining) @@ -189,18 +266,6 @@ class WindowlessCglContext::Configuration: public GL::Context::Configuration { /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - Configuration& setFlags(Flags flags) { - GL::Context::Configuration::setFlags(flags); - return *this; - } - Configuration& addFlags(Flags flags) { - GL::Context::Configuration::addFlags(flags); - return *this; - } - Configuration& clearFlags(Flags flags) { - GL::Context::Configuration::clearFlags(flags); - return *this; - } MAGNUM_GL_CONTEXT_CONFIGURATION_SUBCLASS_IMPLEMENTATION(Configuration) #endif diff --git a/src/Magnum/Platform/WindowlessIosApplication.h b/src/Magnum/Platform/WindowlessIosApplication.h index d02e92b07..472e6d92f 100644 --- a/src/Magnum/Platform/WindowlessIosApplication.h +++ b/src/Magnum/Platform/WindowlessIosApplication.h @@ -154,23 +154,87 @@ class WindowlessIosContext { */ class WindowlessIosContext::Configuration: public GL::Context::Configuration { public: - /* Overloads to remove WTF-factor from method chaining order */ - #ifndef DOXYGEN_GENERATING_OUTPUT + /** + * @brief Context flag + * + * Includes also everything from @ref GL::Context::Configuration::Flag. + * @see @ref Flags, @ref setFlags(), @ref GL::Context::Flag + */ + enum class Flag: UnsignedLong { + /** + * @copydoc GL::Context::Configuration::Flag::QuietLog + * @m_since_latest + */ + QuietLog = UnsignedLong(GL::Context::Configuration::Flag::QuietLog), + + /** + * @copydoc GL::Context::Configuration::Flag::VerboseLog + * @m_since_latest + */ + VerboseLog = UnsignedLong(GL::Context::Configuration::Flag::VerboseLog), + + /** + * @copydoc GL::Context::Configuration::Flag::GpuValidation + * @m_since_latest + */ + GpuValidation = UnsignedLong(GL::Context::Configuration::Flag::GpuValidation) + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + typedef Containers::EnumSet Flags; + + /** @brief Context flags */ + Flags flags() const { + return Flag(UnsignedLong(GL::Context::Configuration::flags())); + } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. To avoid clearing default flags by accident, + * prefer to use @ref addFlags() and @ref clearFlags() instead. + * @see @ref GL::Context::flags() + */ Configuration& setFlags(Flags flags) { - GL::Context::Configuration::setFlags(flags); + GL::Context::Configuration::setFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); return *this; } + + /** + * @brief Add context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ORs the flags with existing instead of + * replacing them. Useful for preserving the defaults. + * @see @ref clearFlags() + */ Configuration& addFlags(Flags flags) { - GL::Context::Configuration::addFlags(flags); + GL::Context::Configuration::addFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); return *this; } + + /** + * @brief Clear context flags + * @return Reference to self (for method chaining) + * + * Unlike @ref setFlags(), ANDs the inverse of @p flags with existing + * instead of replacing them. Useful for removing default flags. + * @see @ref addFlags() + */ Configuration& clearFlags(Flags flags) { - GL::Context::Configuration::clearFlags(flags); + GL::Context::Configuration::clearFlags(GL::Context::Configuration::Flag(UnsignedLong(flags))); return *this; } + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT MAGNUM_GL_CONTEXT_CONFIGURATION_SUBCLASS_IMPLEMENTATION(Configuration) #endif - }; /**