Browse Source

Debug output for Context::DetectedDriver[s].

pull/203/merge
Vladimír Vondruš 9 years ago
parent
commit
d101ced2b4
  1. 36
      src/Magnum/Context.cpp
  2. 9
      src/Magnum/Context.h
  3. 30
      src/Magnum/Test/ContextTest.cpp

36
src/Magnum/Context.cpp

@ -860,8 +860,8 @@ void Context::resetState(const States states) {
#endif
}
#ifndef MAGNUM_TARGET_WEBGL
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_WEBGL
Debug& operator<<(Debug& debug, const Context::Flag value) {
switch(value) {
/* LCOV_EXCL_START */
@ -888,6 +888,40 @@ Debug& operator<<(Debug& debug, const Context::Flags value) {
});
}
#endif
Debug& operator<<(Debug& debug, const Context::DetectedDriver value) {
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case Context::DetectedDriver::value: return debug << "Context::DetectedDriver::" #value;
#ifndef MAGNUM_TARGET_WEBGL
_c(AMD)
_c(IntelWindows)
_c(Mesa)
_c(NVidia)
#endif
#ifdef MAGNUM_TARGET_GLES
_c(ProbablyAngle)
#endif
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "Context::DetectedDriver(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const Context::DetectedDrivers value) {
return Containers::enumSetDebugOutput(debug, value, "Context::DetectedDrivers{}", {
#ifndef MAGNUM_TARGET_WEBGL
Context::DetectedDriver::AMD,
Context::DetectedDriver::IntelWindows,
Context::DetectedDriver::Mesa,
Context::DetectedDriver::NVidia,
#endif
#ifdef MAGNUM_TARGET_GLES
Context::DetectedDriver::ProbablyAngle
#endif
});
}
#endif
}

9
src/Magnum/Context.h

@ -527,7 +527,8 @@ class MAGNUM_EXPORT Context {
*
* Tries to detect driver using various OpenGL state queries. Once the
* detection is done, the result is cached, repeated queries don't
* result in repeated GL calls.
* result in repeated GL calls. Used primarily for enabling
* driver-specific workarounds.
*/
DetectedDrivers detectedDriver();
@ -589,6 +590,12 @@ MAGNUM_EXPORT Debug& operator<<(Debug& debug, Context::Flag value);
MAGNUM_EXPORT Debug& operator<<(Debug& debug, Context::Flags value);
#endif
/** @debugoperatorclassenum{Magnum::Context,Magnum::Context::DetectedDriver} */
MAGNUM_EXPORT Debug& operator<<(Debug& debug, Context::DetectedDriver value);
/** @debugoperatorclassenum{Magnum::Context,Magnum::Context::DetectedDrivers} */
MAGNUM_EXPORT Debug& operator<<(Debug& debug, Context::DetectedDrivers value);
/** @hideinitializer
@brief Assert that given OpenGL version is supported
@param version Version

30
src/Magnum/Test/ContextTest.cpp

@ -35,11 +35,17 @@ struct ContextTest: TestSuite::Tester {
void debugFlag();
void debugFlags();
void debugDetectedDriver();
void debugDetectedDrivers();
};
ContextTest::ContextTest() {
addTests({&ContextTest::debugFlag,
&ContextTest::debugFlags});
&ContextTest::debugFlags,
&ContextTest::debugDetectedDriver,
&ContextTest::debugDetectedDrivers});
}
void ContextTest::debugFlag() {
@ -62,6 +68,28 @@ void ContextTest::debugFlags() {
#endif
}
void ContextTest::debugDetectedDriver() {
std::ostringstream out;
#ifndef MAGNUM_TARGET_WEBGL
Debug{&out} << Context::DetectedDriver::AMD << Context::DetectedDriver(0xdead);
CORRADE_COMPARE(out.str(), "Context::DetectedDriver::AMD Context::DetectedDriver(0xdead)\n");
#else
Debug{&out} << Context::DetectedDriver::ProbablyAngle << Context::DetectedDriver(0xdead);
CORRADE_COMPARE(out.str(), "Context::DetectedDriver::ProbablyAngle Context::DetectedDriver(0xdead)\n");
#endif
}
void ContextTest::debugDetectedDrivers() {
std::ostringstream out;
#ifndef MAGNUM_TARGET_WEBGL
Debug{&out} << Context::DetectedDrivers{} << (Context::DetectedDriver::AMD|Context::DetectedDriver::NVidia) << (Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00));
CORRADE_COMPARE(out.str(), "Context::DetectedDrivers{} Context::DetectedDriver::AMD|Context::DetectedDriver::NVidia Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00)\n");
#else
Debug{&out} << Context::DetectedDrivers{} << (Context::DetectedDriver::ProbablyAngle) << (Context::DetectedDriver::ProbablyAngle|Context::DetectedDriver(0xde00));
CORRADE_COMPARE(out.str(), "Context::DetectedDrivers{} Context::DetectedDriver::ProbablyAngle Context::DetectedDriver::ProbablyAngle|Context::DetectedDriver(0xde00)\n");
#endif
}
}}
CORRADE_TEST_MAIN(Magnum::Test::ContextTest)

Loading…
Cancel
Save