From 9e4ccf6a5525d8b34f41b337a82898137c5d3779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 21 Apr 2018 16:26:28 +0200 Subject: [PATCH] Split the OpenGL layer out, pt 13: renamed GL-related macros. The MAGNUM_ASSERT_VERSION_SUPPORTED(), MAGNUM_ASSERT_EXTENSION_SUPPORTED(), MAGNUM_VERIFY_NO_ERROR() macros are now MAGNUM_ASSERT_GL_VERSION_SUPPORTED(), MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() and MAGNUM_VERIFY_NO_GL_ERROR(). Backwards-compatible aliases are in the original headers, as usual. --- doc/changelog.dox | 5 ++++ doc/portability.dox | 4 ++-- doc/snippets/MagnumGL.cpp | 12 +++++----- src/Magnum/GL/Context.h | 44 ++++++++++++++++++++++++------------ src/Magnum/GL/Extensions.h | 2 +- src/Magnum/GL/OpenGLTester.h | 17 ++++++++++---- src/Magnum/GL/Version.h | 2 +- 7 files changed, 56 insertions(+), 30 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 63d0c340e..533035fc4 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -171,6 +171,11 @@ See also: @ref Magnum namespace were moved to @ref Magnum/GL directory and @ref Magnum::GL namespace. See their documentation for information about particular files, classes, enums, typedefs, values and functions. +- The `MAGNUM_ASSERT_VERSION_SUPPORTED()`, `MAGNUM_ASSERT_EXTENSION_SUPPORTED()` + and `MAGNUM_VERIFY_NO_ERROR()` macros are deprecated, use + @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED(), + @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() and + @ref MAGNUM_VERIFY_NO_GL_ERROR() instead - The @ref PixelFormat and @ref CompressedPixelFormat enum now contains generic API-independent values. The GL-specific formats are present there, but marked as deprecated. Use either the generic values or diff --git a/doc/portability.dox b/doc/portability.dox index 9d73d78ff..4007c306a 100644 --- a/doc/portability.dox +++ b/doc/portability.dox @@ -86,8 +86,8 @@ that version might be available even if the drivers don't fully expose that version. On the other hand, if you don't want to write fallback code for unsupported -extensions, you can use macros @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() or -@ref MAGNUM_ASSERT_VERSION_SUPPORTED() to add mandatory requirement of given +extensions, you can use macros @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() or +@ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED() to add mandatory requirement of given extension or version: @snippet MagnumGL.cpp portability-extension-assert diff --git a/doc/snippets/MagnumGL.cpp b/doc/snippets/MagnumGL.cpp index 12373900b..0717e9d4c 100644 --- a/doc/snippets/MagnumGL.cpp +++ b/doc/snippets/MagnumGL.cpp @@ -571,13 +571,13 @@ if(Context::current().isExtensionSupported @@ -495,7 +495,7 @@ class MAGNUM_GL_EXPORT Context { /** * @brief Whether given OpenGL version is supported * - * @see @ref supportedVersion(), @ref MAGNUM_ASSERT_VERSION_SUPPORTED() + * @see @ref supportedVersion(), @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED() */ bool isVersionSupported(Version version) const; @@ -524,7 +524,7 @@ class MAGNUM_GL_EXPORT Context { * @snippet MagnumGL.cpp Context-isExtensionSupported * * @see @ref isExtensionSupported(const Extension&) const, - * @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED(), + * @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(), * @ref isExtensionDisabled() */ template bool isExtensionSupported() const { @@ -552,7 +552,7 @@ class MAGNUM_GL_EXPORT Context { * hardware, but for general usage prefer @ref isExtensionSupported() const, * as it does most operations in compile time. * @see @ref supportedExtensions(), @ref Extension::extensions(), - * @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() + * @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() */ bool isExtensionSupported(const Extension& extension) const { return isVersionSupported(_extensionRequiredVersion[extension.index()]) && _extensionStatus[extension.index()]; @@ -700,18 +700,18 @@ By default, if assertion fails, an message is printed to error output and the application aborts. If `CORRADE_NO_ASSERT` is defined, this macro does nothing. Example usage: -@snippet MagnumGL.cpp Context-MAGNUM_ASSERT_VERSION_SUPPORTED +@snippet MagnumGL.cpp Context-MAGNUM_ASSERT_GL_VERSION_SUPPORTED @see @ref Magnum::GL::Context::isVersionSupported() "GL::Context::isVersionSupported()", - @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED(), @ref CORRADE_ASSERT(), + @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(), @ref CORRADE_ASSERT(), @ref CORRADE_INTERNAL_ASSERT() */ #ifdef CORRADE_NO_ASSERT -#define MAGNUM_ASSERT_VERSION_SUPPORTED(version) do {} while(0) +#define MAGNUM_ASSERT_GL_VERSION_SUPPORTED(version) do {} while(0) #else -#define MAGNUM_ASSERT_VERSION_SUPPORTED(version) \ +#define MAGNUM_ASSERT_GL_VERSION_SUPPORTED(version) \ do { \ - if(!Magnum::Context::current().isVersionSupported(version)) { \ + if(!Magnum::GL::Context::current().isVersionSupported(version)) { \ Corrade::Utility::Error() << "Magnum: required version" << version << "is not supported"; \ std::abort(); \ } \ @@ -729,18 +729,18 @@ By default, if assertion fails, an message is printed to error output and the application aborts. If `CORRADE_NO_ASSERT` is defined, this macro does nothing. Example usage: -@snippet MagnumGL.cpp Context-MAGNUM_ASSERT_EXTENSION_SUPPORTED +@snippet MagnumGL.cpp Context-MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED -@see @ref Magnum::Context::isExtensionSupported() "Context::isExtensionSupported()", - @ref MAGNUM_ASSERT_VERSION_SUPPORTED(), @ref CORRADE_ASSERT(), +@see @ref Magnum::GL::Context::isExtensionSupported() "Context::isExtensionSupported()", + @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED(), @ref CORRADE_ASSERT(), @ref CORRADE_INTERNAL_ASSERT() */ #ifdef CORRADE_NO_ASSERT -#define MAGNUM_ASSERT_EXTENSION_SUPPORTED(extension) do {} while(0) +#define MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(extension) do {} while(0) #else -#define MAGNUM_ASSERT_EXTENSION_SUPPORTED(extension) \ +#define MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(extension) \ do { \ - if(!Magnum::Context::current().isExtensionSupported()) { \ + if(!Magnum::GL::Context::current().isExtensionSupported()) { \ Corrade::Utility::Error() << "Magnum: required extension" << extension::string() << "is not supported"; \ std::abort(); \ } \ @@ -761,6 +761,20 @@ typedef CORRADE_DEPRECATED("use GL::Extension instead") Magnum::GL::Extension Ex * @deprecated Use @ref GL::Context instead. */ typedef CORRADE_DEPRECATED("use GL::Context instead") Magnum::GL::Context Context; + +/** @brief @copybrief MAGNUM_ASSERT_GL_VERSION_SUPPORTED() + * @deprecated Use @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED() + */ +#define MAGNUM_ASSERT_VERSION_SUPPORTED(version) \ + CORRADE_DEPRECATED_MACRO(MAGNUM_ASSERT_VERSION_SUPPORTED(), "use MAGNUM_ASSERT_GL_VERSION_SUPPORTED() instead") \ + MAGNUM_ASSERT_GL_VERSION_SUPPORTED(version) + +/** @brief @copybrief MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() + * @deprecated Use @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() + */ +#define MAGNUM_ASSERT_EXTENSION_SUPPORTED(extension) \ + CORRADE_DEPRECATED_MACRO(MAGNUM_ASSERT_EXTENSION_SUPPORTED(), "use MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() instead") \ + MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(extension) #endif } diff --git a/src/Magnum/GL/Extensions.h b/src/Magnum/GL/Extensions.h index 412fae910..fc5fd916f 100644 --- a/src/Magnum/GL/Extensions.h +++ b/src/Magnum/GL/Extensions.h @@ -72,7 +72,7 @@ target_link_libraries(your-app Magnum::GL) @endcode See @ref building, @ref cmake and @ref opengl for more information. -@see @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() +@see @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() */ namespace Extensions { diff --git a/src/Magnum/GL/OpenGLTester.h b/src/Magnum/GL/OpenGLTester.h index 182f9b612..94732ae9d 100644 --- a/src/Magnum/GL/OpenGLTester.h +++ b/src/Magnum/GL/OpenGLTester.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Class @ref Magnum::GL::OpenGLTester + * @brief Class @ref Magnum::GL::OpenGLTester, macro @ref MAGNUM_VERIFY_NO_GL_ERROR() */ #include @@ -122,8 +122,8 @@ On platforms that support it, the OpenGL context is created with synchronous debug output, meaning that every OpenGL error is directly reported to standard output. While it is possible, the tester class doesn't abort the test cases upon encountering a GL error --- this should be done explicitly with -@ref MAGNUM_VERIFY_NO_ERROR() instead, as the debug output is not available on -all platforms and not all GL errors are fatal. +@ref MAGNUM_VERIFY_NO_GL_ERROR() instead, as the debug output is not available +on all platforms and not all GL errors are fatal. @section GL-OpenGLTester-benchmarks GPU time benchmarks @@ -271,9 +271,9 @@ class OpenGLTester: public TestSuite::Tester { Equivalent to -@snippet MagnumGL.cpp OpenGLTester-MAGNUM_VERIFY_NO_ERROR +@snippet MagnumGL.cpp OpenGLTester-MAGNUM_VERIFY_NO_GL_ERROR */ -#define MAGNUM_VERIFY_NO_ERROR() CORRADE_COMPARE(Magnum::Renderer::error(), Magnum::Renderer::Error::NoError) +#define MAGNUM_VERIFY_NO_GL_ERROR() CORRADE_COMPARE(Magnum::GL::Renderer::error(), Magnum::GL::Renderer::Error::NoError) } @@ -284,6 +284,13 @@ Equivalent to * @deprecated Use @ref GL::OpenGLTester instead. */ typedef CORRADE_DEPRECATED("use GL::OpenGLTester instead") Magnum::GL::OpenGLTester OpenGLTester; + +/** @brief @copybrief MAGNUM_VERIFY_NO_GL_ERROR() + * @deprecated Use @ref MAGNUM_VERIFY_NO_GL_ERROR() instead. +*/ +#define MAGNUM_VERIFY_NO_ERROR() \ + CORRADE_DEPRECATED_MACRO(MAGNUM_VERIFY_NO_ERROR(),"use MAGNUM_VERIFY_NO_GL_ERROR() instead") \ + MAGNUM_VERIFY_NO_GL_ERROR() #endif } diff --git a/src/Magnum/GL/Version.h b/src/Magnum/GL/Version.h index 56a482b60..81e7c43be 100644 --- a/src/Magnum/GL/Version.h +++ b/src/Magnum/GL/Version.h @@ -45,7 +45,7 @@ namespace Implementation { /** @brief OpenGL version -@see @ref version(), @ref Context, @ref MAGNUM_ASSERT_VERSION_SUPPORTED() +@see @ref version(), @ref Context, @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED() */ enum class Version: Int { None = 0xFFFF, /**< Unspecified */