Browse Source

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.
pull/233/head
Vladimír Vondruš 8 years ago
parent
commit
9e4ccf6a55
  1. 5
      doc/changelog.dox
  2. 4
      doc/portability.dox
  3. 12
      doc/snippets/MagnumGL.cpp
  4. 44
      src/Magnum/GL/Context.h
  5. 2
      src/Magnum/GL/Extensions.h
  6. 17
      src/Magnum/GL/OpenGLTester.h
  7. 2
      src/Magnum/GL/Version.h

5
doc/changelog.dox

@ -171,6 +171,11 @@ See also:
@ref Magnum namespace were moved to @ref Magnum/GL directory and @ref Magnum namespace were moved to @ref Magnum/GL directory and
@ref Magnum::GL namespace. See their documentation for information about @ref Magnum::GL namespace. See their documentation for information about
particular files, classes, enums, typedefs, values and functions. 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 - The @ref PixelFormat and @ref CompressedPixelFormat enum now contains
generic API-independent values. The GL-specific formats are present there, generic API-independent values. The GL-specific formats are present there,
but marked as deprecated. Use either the generic values or but marked as deprecated. Use either the generic values or

4
doc/portability.dox

@ -86,8 +86,8 @@ that version might be available even if the drivers don't fully expose that
version. version.
On the other hand, if you don't want to write fallback code for unsupported 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 extensions, you can use macros @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED() or
@ref MAGNUM_ASSERT_VERSION_SUPPORTED() to add mandatory requirement of given @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED() to add mandatory requirement of given
extension or version: extension or version:
@snippet MagnumGL.cpp portability-extension-assert @snippet MagnumGL.cpp portability-extension-assert

12
doc/snippets/MagnumGL.cpp

@ -571,13 +571,13 @@ if(Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_
} }
/* [Context-isExtensionSupported-version] */ /* [Context-isExtensionSupported-version] */
/* [Context-MAGNUM_ASSERT_VERSION_SUPPORTED] */ /* [Context-MAGNUM_ASSERT_GL_VERSION_SUPPORTED] */
MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL330); MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL330);
/* [Context-MAGNUM_ASSERT_VERSION_SUPPORTED] */ /* [Context-MAGNUM_ASSERT_GL_VERSION_SUPPORTED] */
/* [Context-MAGNUM_ASSERT_EXTENSION_SUPPORTED] */ /* [Context-MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED] */
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4);
/* [Context-MAGNUM_ASSERT_EXTENSION_SUPPORTED] */ /* [Context-MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED] */
} }
#endif #endif
@ -1109,9 +1109,9 @@ texture.setStorage(16, TextureFormat::RGBA8, {1024, 1024});
#if !defined(MAGNUM_TARGET_WEBGL) && !defined(CORRADE_TARGET_ANDROID) #if !defined(MAGNUM_TARGET_WEBGL) && !defined(CORRADE_TARGET_ANDROID)
struct A: TestSuite::Tester { struct A: TestSuite::Tester {
void foo() { void foo() {
/* [OpenGLTester-MAGNUM_VERIFY_NO_ERROR] */ /* [OpenGLTester-MAGNUM_VERIFY_NO_GL_ERROR] */
CORRADE_COMPARE(Magnum::Renderer::error(), Magnum::Renderer::Error::NoError); CORRADE_COMPARE(Magnum::Renderer::error(), Magnum::Renderer::Error::NoError);
/* [OpenGLTester-MAGNUM_VERIFY_NO_ERROR] */ /* [OpenGLTester-MAGNUM_VERIFY_NO_GL_ERROR] */
} }
}; };
#endif #endif

44
src/Magnum/GL/Context.h

@ -26,7 +26,7 @@
*/ */
/** @file /** @file
* @brief Class @ref Magnum::GL::Context, @ref Magnum::GL::Extension, macro @ref MAGNUM_ASSERT_VERSION_SUPPORTED(), @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() * @brief Class @ref Magnum::GL::Context, @ref Magnum::GL::Extension, macro @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED(), @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED()
*/ */
#include <cstdlib> #include <cstdlib>
@ -495,7 +495,7 @@ class MAGNUM_GL_EXPORT Context {
/** /**
* @brief Whether given OpenGL version is supported * @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; bool isVersionSupported(Version version) const;
@ -524,7 +524,7 @@ class MAGNUM_GL_EXPORT Context {
* @snippet MagnumGL.cpp Context-isExtensionSupported * @snippet MagnumGL.cpp Context-isExtensionSupported
* *
* @see @ref isExtensionSupported(const Extension&) const, * @see @ref isExtensionSupported(const Extension&) const,
* @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED(), * @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(),
* @ref isExtensionDisabled() * @ref isExtensionDisabled()
*/ */
template<class T> bool isExtensionSupported() const { template<class T> bool isExtensionSupported() const {
@ -552,7 +552,7 @@ class MAGNUM_GL_EXPORT Context {
* hardware, but for general usage prefer @ref isExtensionSupported() const, * hardware, but for general usage prefer @ref isExtensionSupported() const,
* as it does most operations in compile time. * as it does most operations in compile time.
* @see @ref supportedExtensions(), @ref Extension::extensions(), * @see @ref supportedExtensions(), @ref Extension::extensions(),
* @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() * @ref MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED()
*/ */
bool isExtensionSupported(const Extension& extension) const { bool isExtensionSupported(const Extension& extension) const {
return isVersionSupported(_extensionRequiredVersion[extension.index()]) && _extensionStatus[extension.index()]; 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. application aborts. If `CORRADE_NO_ASSERT` is defined, this macro does nothing.
Example usage: 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()", @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() @ref CORRADE_INTERNAL_ASSERT()
*/ */
#ifdef CORRADE_NO_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 #else
#define MAGNUM_ASSERT_VERSION_SUPPORTED(version) \ #define MAGNUM_ASSERT_GL_VERSION_SUPPORTED(version) \
do { \ do { \
if(!Magnum::Context::current().isVersionSupported(version)) { \ if(!Magnum::GL::Context::current().isVersionSupported(version)) { \
Corrade::Utility::Error() << "Magnum: required version" << version << "is not supported"; \ Corrade::Utility::Error() << "Magnum: required version" << version << "is not supported"; \
std::abort(); \ 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. application aborts. If `CORRADE_NO_ASSERT` is defined, this macro does nothing.
Example usage: 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()", @see @ref Magnum::GL::Context::isExtensionSupported() "Context::isExtensionSupported()",
@ref MAGNUM_ASSERT_VERSION_SUPPORTED(), @ref CORRADE_ASSERT(), @ref MAGNUM_ASSERT_GL_VERSION_SUPPORTED(), @ref CORRADE_ASSERT(),
@ref CORRADE_INTERNAL_ASSERT() @ref CORRADE_INTERNAL_ASSERT()
*/ */
#ifdef CORRADE_NO_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 #else
#define MAGNUM_ASSERT_EXTENSION_SUPPORTED(extension) \ #define MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(extension) \
do { \ do { \
if(!Magnum::Context::current().isExtensionSupported<extension>()) { \ if(!Magnum::GL::Context::current().isExtensionSupported<extension>()) { \
Corrade::Utility::Error() << "Magnum: required extension" << extension::string() << "is not supported"; \ Corrade::Utility::Error() << "Magnum: required extension" << extension::string() << "is not supported"; \
std::abort(); \ std::abort(); \
} \ } \
@ -761,6 +761,20 @@ typedef CORRADE_DEPRECATED("use GL::Extension instead") Magnum::GL::Extension Ex
* @deprecated Use @ref GL::Context instead. * @deprecated Use @ref GL::Context instead.
*/ */
typedef CORRADE_DEPRECATED("use GL::Context instead") Magnum::GL::Context Context; 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 #endif
} }

2
src/Magnum/GL/Extensions.h

@ -72,7 +72,7 @@ target_link_libraries(your-app Magnum::GL)
@endcode @endcode
See @ref building, @ref cmake and @ref opengl for more information. 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 { namespace Extensions {

17
src/Magnum/GL/OpenGLTester.h

@ -26,7 +26,7 @@
*/ */
/** @file /** @file
* @brief Class @ref Magnum::GL::OpenGLTester * @brief Class @ref Magnum::GL::OpenGLTester, macro @ref MAGNUM_VERIFY_NO_GL_ERROR()
*/ */
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
@ -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 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 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 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 @ref MAGNUM_VERIFY_NO_GL_ERROR() instead, as the debug output is not available
all platforms and not all GL errors are fatal. on all platforms and not all GL errors are fatal.
@section GL-OpenGLTester-benchmarks GPU time benchmarks @section GL-OpenGLTester-benchmarks GPU time benchmarks
@ -271,9 +271,9 @@ class OpenGLTester: public TestSuite::Tester {
Equivalent to 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. * @deprecated Use @ref GL::OpenGLTester instead.
*/ */
typedef CORRADE_DEPRECATED("use GL::OpenGLTester instead") Magnum::GL::OpenGLTester OpenGLTester; 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 #endif
} }

2
src/Magnum/GL/Version.h

@ -45,7 +45,7 @@ namespace Implementation {
/** /**
@brief OpenGL version @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 { enum class Version: Int {
None = 0xFFFF, /**< Unspecified */ None = 0xFFFF, /**< Unspecified */

Loading…
Cancel
Save