Browse Source

Added function to query whether given extension is disabled.

pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
3e16f7ac58
  1. 36
      src/Magnum/Context.h
  2. 16
      src/Magnum/Test/ContextGLTest.cpp

36
src/Magnum/Context.h

@ -288,7 +288,8 @@ class MAGNUM_EXPORT Context {
* @endcode
*
* @see isExtensionSupported(const Extension&) const,
* @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED()
* @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED(),
* @ref isExtensionDisabled()
* @todoc Explicit reference when Doxygen is sane
*/
template<class T> bool isExtensionSupported() const {
@ -327,6 +328,39 @@ class MAGNUM_EXPORT Context {
return isVersionSupported(_extensionRequiredVersion[extension._index]) && extensionStatus[extension._index];
}
/**
* @brief Whether given extension is supported by the driver but disabled
*
* Can be used for detecting driver bug workarounds. Disabled
* extensions return `false` in @ref isExtensionSupported() even if
* they are advertised as being supported by the driver.
*/
template<class T> bool isExtensionDisabled() const {
return isExtensionDisabled<T>(version());
}
/**
* @brief Whether given extension is supported by the driver but disabled for given version
*
* Similar to above, but can also check for extensions which are
* disabled only for particular versions.
*/
template<class T> bool isExtensionDisabled(Version version) const {
/* The extension is advertised, but the minimal version has been increased */
return T::requiredVersion() <= version && extensionStatus[T::Index] && _extensionRequiredVersion[T::Index] > version;
}
/**
* @brief Whether given extension is supported by the driver but disabled
*
* Can be used e.g. for listing extensions available on current
* hardware, but for general usage prefer isExtensionDisabled() const,
* as it does most operations in compile time.
*/
bool isExtensionDisabled(const Extension& extension) const {
return isVersionSupported(extension._requiredVersion) && extensionStatus[extension._index] && !isVersionSupported(_extensionRequiredVersion[extension._index]);
}
#ifndef DOXYGEN_GENERATING_OUTPUT
Implementation::State& state() { return *_state; }
#endif

16
src/Magnum/Test/ContextGLTest.cpp

@ -36,12 +36,14 @@ class ContextGLTest: public AbstractOpenGLTester {
void isVersionSupported();
void supportedVersion();
void isExtensionSupported();
void isExtensionDisabled();
};
ContextGLTest::ContextGLTest() {
addTests({&ContextGLTest::isVersionSupported,
&ContextGLTest::supportedVersion,
&ContextGLTest::isExtensionSupported});
&ContextGLTest::isExtensionSupported,
&ContextGLTest::isExtensionDisabled});
}
void ContextGLTest::isVersionSupported() {
@ -80,6 +82,18 @@ void ContextGLTest::isExtensionSupported() {
#endif
}
void ContextGLTest::isExtensionDisabled() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::APPLE::vertex_array_object>())
CORRADE_SKIP(Extensions::GL::APPLE::vertex_array_object::string() + std::string(" extension should be supported, can't test"));
/* This is not disabled anywhere */
CORRADE_VERIFY(!Context::current()->isExtensionDisabled<Extensions::GL::APPLE::vertex_array_object>());
#else
CORRADE_SKIP("No useful extensions to test on OpenGL ES");
#endif
}
}}
CORRADE_TEST_MAIN(Magnum::Test::ContextGLTest)

Loading…
Cancel
Save