Browse Source

GL: debug output for DynamicAttribute enums.

Forgotten, apparently.
findsdl-include-root
Vladimír Vondruš 7 years ago
parent
commit
b2494416f4
  1. 74
      src/Magnum/GL/Attribute.cpp
  2. 9
      src/Magnum/GL/Attribute.h
  3. 28
      src/Magnum/GL/Test/AttributeTest.cpp

74
src/Magnum/GL/Attribute.cpp

@ -28,7 +28,75 @@
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Debug.h>
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<void*>(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<void*>(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<void*>(GLenum(value)) << Debug::nospace << ")";
}
namespace Implementation {
UnsignedInt FloatAttribute::size(GLint components, DataType dataType) {
switch(dataType) {
@ -365,4 +433,6 @@ Debug& operator<<(Debug& debug, Attribute<Math::Vector<4, Float>>::DataType valu
return debug << "GL::Attribute::DataType(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
}
}}}
}
}}

9
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 */

28
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)

Loading…
Cancel
Save