diff --git a/src/Magnum/GL/Attribute.cpp b/src/Magnum/GL/Attribute.cpp index 129ed92c8..eb6d7b96d 100644 --- a/src/Magnum/GL/Attribute.cpp +++ b/src/Magnum/GL/Attribute.cpp @@ -28,7 +28,75 @@ #include #include -namespace Magnum { namespace GL { namespace Implementation { +namespace Magnum { namespace GL { + +Debug& operator<<(Debug& debug, DynamicAttribute::Kind value) { + switch(value) { + /* LCOV_EXCL_START */ + #define _c(value) case DynamicAttribute::Kind::value: return debug << "GL::DynamicAttribute::Kind::" #value; + _c(Generic) + _c(GenericNormalized) + #ifndef MAGNUM_TARGET_GLES2 + _c(Integral) + #ifndef MAGNUM_TARGET_GLES + _c(Long) + #endif + #endif + #undef _c + /* LCOV_EXCL_STOP */ + } + + return debug << "GL::DynamicAttribute::Kind(" << Debug::nospace << reinterpret_cast(GLenum(value)) << Debug::nospace << ")"; +} + +Debug& operator<<(Debug& debug, DynamicAttribute::Components value) { + switch(value) { + /* LCOV_EXCL_START */ + #define _c(value) case DynamicAttribute::Components::value: return debug << "GL::DynamicAttribute::Components::" #value; + _c(One) + _c(Two) + _c(Three) + _c(Four) + #ifndef MAGNUM_TARGET_GLES + _c(BGRA) + #endif + #undef _c + /* LCOV_EXCL_STOP */ + } + + return debug << "GL::DynamicAttribute::Components(" << Debug::nospace << reinterpret_cast(GLint(value)) << Debug::nospace << ")"; +} + +Debug& operator<<(Debug& debug, DynamicAttribute::DataType value) { + switch(value) { + /* LCOV_EXCL_START */ + #define _c(value) case DynamicAttribute::DataType::value: return debug << "GL::DynamicAttribute::DataType::" #value; + _c(UnsignedByte) + _c(Byte) + _c(UnsignedShort) + _c(Short) + _c(UnsignedInt) + _c(Int) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + _c(HalfFloat) + #endif + _c(Float) + #ifndef MAGNUM_TARGET_GLES + _c(Double) + _c(UnsignedInt10f11f11fRev) + #endif + #ifndef MAGNUM_TARGET_GLES2 + _c(UnsignedInt2101010Rev) + _c(Int2101010Rev) + #endif + #undef _c + /* LCOV_EXCL_STOP */ + } + + return debug << "GL::DynamicAttribute::DataType(" << Debug::nospace << reinterpret_cast(GLenum(value)) << Debug::nospace << ")"; +} + +namespace Implementation { UnsignedInt FloatAttribute::size(GLint components, DataType dataType) { switch(dataType) { @@ -365,4 +433,6 @@ Debug& operator<<(Debug& debug, Attribute>::DataType valu return debug << "GL::Attribute::DataType(" << Debug::nospace << reinterpret_cast(GLenum(value)) << Debug::nospace << ")"; } -}}} +} + +}} diff --git a/src/Magnum/GL/Attribute.h b/src/Magnum/GL/Attribute.h index 3d2a7f1df..207dfd583 100644 --- a/src/Magnum/GL/Attribute.h +++ b/src/Magnum/GL/Attribute.h @@ -534,6 +534,15 @@ class DynamicAttribute { DataType _dataType; }; +/** @debugoperatorclassenum{DynamicAttribute,DynamicAttribute::Kind} */ +MAGNUM_GL_EXPORT Debug& operator<<(Debug& debug, DynamicAttribute::Kind); + +/** @debugoperatorclassenum{DynamicAttribute,DynamicAttribute::Components} */ +MAGNUM_GL_EXPORT Debug& operator<<(Debug& debug, DynamicAttribute::Components); + +/** @debugoperatorclassenum{DynamicAttribute,DynamicAttribute::DataType} */ +MAGNUM_GL_EXPORT Debug& operator<<(Debug& debug, DynamicAttribute::DataType); + namespace Implementation { /* Base for sized attributes */ diff --git a/src/Magnum/GL/Test/AttributeTest.cpp b/src/Magnum/GL/Test/AttributeTest.cpp index fe103306b..9e70f404a 100644 --- a/src/Magnum/GL/Test/AttributeTest.cpp +++ b/src/Magnum/GL/Test/AttributeTest.cpp @@ -72,6 +72,10 @@ struct AttributeTest: TestSuite::Tester { #endif void debugDataTypeVector3(); void debugDataTypeVector4(); + + void debugDynamicKind(); + void debugDynamicComponents(); + void debugDynamicDataType(); }; AttributeTest::AttributeTest() { @@ -112,7 +116,11 @@ AttributeTest::AttributeTest() { &AttributeTest::debugDataTypeDouble, #endif &AttributeTest::debugDataTypeVector3, - &AttributeTest::debugDataTypeVector4}); + &AttributeTest::debugDataTypeVector4, + + &AttributeTest::debugDynamicKind, + &AttributeTest::debugDynamicComponents, + &AttributeTest::debugDynamicDataType}); } void AttributeTest::attributeScalar() { @@ -472,6 +480,24 @@ void AttributeTest::debugDataTypeVector4() { CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n"); } +void AttributeTest::debugDynamicKind() { + std::ostringstream out; + Debug{&out} << DynamicAttribute::Kind::GenericNormalized << DynamicAttribute::Kind(0xdead); + CORRADE_COMPARE(out.str(), "GL::DynamicAttribute::Kind::GenericNormalized GL::DynamicAttribute::Kind(0xdead)\n"); +} + +void AttributeTest::debugDynamicComponents() { + std::ostringstream out; + Debug{&out} << DynamicAttribute::Components::Three << DynamicAttribute::Components(0xdead); + CORRADE_COMPARE(out.str(), "GL::DynamicAttribute::Components::Three GL::DynamicAttribute::Components(0xdead)\n"); +} + +void AttributeTest::debugDynamicDataType() { + std::ostringstream out; + Debug{&out} << DynamicAttribute::DataType::Float << DynamicAttribute::DataType(0xdead); + CORRADE_COMPARE(out.str(), "GL::DynamicAttribute::DataType::Float GL::DynamicAttribute::DataType(0xdead)\n"); +} + }}}} CORRADE_TEST_MAIN(Magnum::GL::Test::AttributeTest)