From 980503a5092ae465cc44566aaa2bf537cbdd5a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 6 Mar 2014 22:20:00 +0100 Subject: [PATCH] Renamed AbstractShaderProgram::Attribute::Type to ScalarType. In all other places (e.g. Math, SceneGraph), SomeClass::Type is always T. I spent twenty minutes figuring out what went wrong, so better have this consistent. Also update the test to check for these, as they apparently were tested only indirectly through the MeshGLTest. --- src/Magnum/AbstractShaderProgram.h | 18 +++++++++--------- src/Magnum/Mesh.h | 6 +++--- src/Magnum/Test/AbstractShaderProgramTest.cpp | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index 4dc6409a8..a4e9d9276 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -960,12 +960,12 @@ template class AbstractShaderProgram::Attribute { }; /** - * @brief Type + * @brief Scalar type * - * Type used in shader code. - * @see @ref DataType + * The underlying scalar type of the attribute. + * @see @ref Type, @ref DataType */ - typedef typename Implementation::Attribute::Type Type; + typedef typename Implementation::Attribute::ScalarType ScalarType; /** * @brief Component count @@ -1222,7 +1222,7 @@ template struct Attribute; /* Base for float attributes */ struct FloatAttribute { - typedef Float Type; + typedef Float ScalarType; enum class DataType: GLenum { UnsignedByte = GL_UNSIGNED_BYTE, @@ -1260,7 +1260,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, FloatAttribute::DataType value); #ifndef MAGNUM_TARGET_GLES2 /* Base for int attributes */ struct IntAttribute { - typedef Int Type; + typedef Int ScalarType; enum class DataType: GLenum { UnsignedByte = GL_UNSIGNED_BYTE, @@ -1282,7 +1282,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, IntAttribute::DataType value); /* Base for unsigned int attributes */ struct UnsignedIntAttribute { - typedef UnsignedInt Type; + typedef UnsignedInt ScalarType; typedef IntAttribute::DataType DataType; constexpr static DataType DefaultDataType = DataType::UnsignedInt; @@ -1299,7 +1299,7 @@ struct UnsignedIntAttribute { #ifndef MAGNUM_TARGET_GLES /* Base for double attributes */ struct DoubleAttribute { - typedef Double Type; + typedef Double ScalarType; enum class DataType: GLenum { Double = GL_DOUBLE @@ -1317,7 +1317,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, DoubleAttribute::DataType value); /* Floating-point four-component vector is absolutely special case */ template<> struct Attribute> { - typedef Float Type; + typedef Float ScalarType; enum class Components: GLint { One = 1, diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index 6afd3441d..692b1940b 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -703,7 +703,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { } void addVertexBufferInternal(Buffer&, GLsizei, GLintptr) {} - template void addVertexAttribute(typename std::enable_if::Type, Float>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { + template void addVertexAttribute(typename std::enable_if::ScalarType, Float>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { for(UnsignedInt i = 0; i != AbstractShaderProgram::Attribute::VectorCount; ++i) attributePointerInternal(Attribute{ &buffer, @@ -717,7 +717,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { } #ifndef MAGNUM_TARGET_GLES2 - template void addVertexAttribute(typename std::enable_if::Type>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { + template void addVertexAttribute(typename std::enable_if::ScalarType>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { attributePointerInternal(IntegerAttribute{ &buffer, location, @@ -729,7 +729,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { } #ifndef MAGNUM_TARGET_GLES - template void addVertexAttribute(typename std::enable_if::Type, Double>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { + template void addVertexAttribute(typename std::enable_if::ScalarType, Double>::value, Buffer&>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { for(UnsignedInt i = 0; i != AbstractShaderProgram::Attribute::VectorCount; ++i) attributePointerInternal(LongAttribute{ &buffer, diff --git a/src/Magnum/Test/AbstractShaderProgramTest.cpp b/src/Magnum/Test/AbstractShaderProgramTest.cpp index 325e7d561..77317bf1c 100644 --- a/src/Magnum/Test/AbstractShaderProgramTest.cpp +++ b/src/Magnum/Test/AbstractShaderProgramTest.cpp @@ -76,6 +76,7 @@ AbstractShaderProgramTest::AbstractShaderProgramTest() { void AbstractShaderProgramTest::attributeScalar() { typedef AbstractShaderProgram::Attribute<3, Float> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::Location, 3); CORRADE_COMPARE(Attribute::VectorCount, 1); @@ -95,6 +96,7 @@ void AbstractShaderProgramTest::attributeScalar() { void AbstractShaderProgramTest::attributeScalarInt() { #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, Int> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Default constructor */ @@ -112,6 +114,7 @@ void AbstractShaderProgramTest::attributeScalarInt() { void AbstractShaderProgramTest::attributeScalarUnsignedInt() { #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, UnsignedInt> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Default constructor */ @@ -129,6 +132,7 @@ void AbstractShaderProgramTest::attributeScalarUnsignedInt() { void AbstractShaderProgramTest::attributeScalarDouble() { #ifndef MAGNUM_TARGET_GLES typedef AbstractShaderProgram::Attribute<3, Double> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Default constructor */ @@ -141,6 +145,7 @@ void AbstractShaderProgramTest::attributeScalarDouble() { void AbstractShaderProgramTest::attributeVector() { typedef AbstractShaderProgram::Attribute<3, Vector3> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Default constructor */ @@ -164,6 +169,7 @@ void AbstractShaderProgramTest::attributeVector() { void AbstractShaderProgramTest::attributeVectorInt() { #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, Vector2i> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Default constructor */ @@ -183,6 +189,7 @@ void AbstractShaderProgramTest::attributeVectorInt() { void AbstractShaderProgramTest::attributeVectorUnsignedInt() { #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, Vector4ui> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Default constructor */ @@ -202,6 +209,7 @@ void AbstractShaderProgramTest::attributeVectorUnsignedInt() { void AbstractShaderProgramTest::attributeVectorDouble() { #ifndef MAGNUM_TARGET_GLES typedef AbstractShaderProgram::Attribute<3, Vector2d> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Default constructor */ @@ -220,6 +228,7 @@ void AbstractShaderProgramTest::attributeVectorDouble() { void AbstractShaderProgramTest::attributeVector4() { typedef AbstractShaderProgram::Attribute<3, Vector4> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* Custom type */ @@ -235,6 +244,7 @@ void AbstractShaderProgramTest::attributeVector4() { void AbstractShaderProgramTest::attributeVectorBGRA() { #ifndef MAGNUM_TARGET_GLES typedef AbstractShaderProgram::Attribute<3, Vector4> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 1); /* BGRA */ @@ -247,6 +257,7 @@ void AbstractShaderProgramTest::attributeVectorBGRA() { void AbstractShaderProgramTest::attributeMatrixNxN() { typedef AbstractShaderProgram::Attribute<3, Matrix3> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 3); /* Default constructor */ @@ -259,6 +270,7 @@ void AbstractShaderProgramTest::attributeMatrixNxN() { #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgramTest::attributeMatrixMxN() { typedef AbstractShaderProgram::Attribute<3, Matrix3x4> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 3); /* Default constructor */ @@ -272,6 +284,7 @@ void AbstractShaderProgramTest::attributeMatrixMxN() { void AbstractShaderProgramTest::attributeMatrixNxNd() { #ifndef MAGNUM_TARGET_GLES typedef AbstractShaderProgram::Attribute<3, Matrix4d> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 4); /* Default constructor */ @@ -287,6 +300,7 @@ void AbstractShaderProgramTest::attributeMatrixNxNd() { void AbstractShaderProgramTest::attributeMatrixMxNd() { #ifndef MAGNUM_TARGET_GLES typedef AbstractShaderProgram::Attribute<3, Matrix4x2d> Attribute; + CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::VectorCount, 4); /* Default constructor */