From da323625b2646e0bb45b985877abea3ca8996468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 14 Mar 2020 22:25:42 +0100 Subject: [PATCH] GL: rename Attribute::VectorCount to Vectors for consistency. Deprecated alias kept for compatibility, as usual. --- doc/changelog.dox | 3 +++ src/Magnum/GL/Attribute.h | 22 ++++++++++++++------ src/Magnum/GL/Mesh.h | 8 ++++---- src/Magnum/GL/Test/AttributeTest.cpp | 30 ++++++++++++++-------------- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index af5d8a353..fce5828f9 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -426,6 +426,9 @@ See also: are consistent with the @ref Half type used elsewhere. - @cpp GL::Attribute::vectorSize() @ce is deprecated as the name is misleading now, use @ref GL::Attribute::vectorStride() instead +- @cpp GL::Attribute::VectorCount @ce is deprecated in favor of + @ref GL::Attribute::Vectors to have a name consistent with + @ref GL::Attribute::components() - @cpp Trade::AbstractImporter::mesh2D() @ce, @cpp Trade::MeshData2D @ce, @cpp Trade::MeshData3D @ce, @cpp Trade::AbstractImporter::mesh2D() @ce, diff --git a/src/Magnum/GL/Attribute.h b/src/Magnum/GL/Attribute.h index 262ccfd4b..a0d022f5d 100644 --- a/src/Magnum/GL/Attribute.h +++ b/src/Magnum/GL/Attribute.h @@ -80,18 +80,28 @@ template class Attribute { public: enum: UnsignedInt { /** - * Location to which the attribute is bound + * Location to which the attribute is bound. * * @see @ref AbstractShaderProgram::maxVertexAttributes() */ Location = location, /** - * Count of vectors in this type + * Count of vectors in this type. + * @m_since_latest * + * Is @cpp 1 @ce for non-matrix attributes. * @see @ref vectorSize() */ - VectorCount = Implementation::Attribute::VectorCount + Vectors = Implementation::Attribute::Vectors, + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * Count of vectors in this type, + * @m_deprecated_since_latest Use @ref Vectors instead. + */ + VectorCount CORRADE_DEPRECATED_ENUM("use Vectors instead") = Vectors + #endif }; /** @@ -360,7 +370,7 @@ template class Attribute { * @brief Size of each vector in passed data * @m_deprecated_since_latest Use @ref vectorStride() instead. * - * @see @ref VectorCount + * @see @ref Vectors */ constexpr CORRADE_DEPRECATED("use vectorStride() instead") UnsignedInt vectorSize() const { return vectorStride(); @@ -695,7 +705,7 @@ template struct SizedAttribute; /* Vector attribute sizes */ template struct SizedVectorAttribute { - enum: UnsignedInt { VectorCount = UnsignedInt(cols) }; + enum: UnsignedInt { Vectors = UnsignedInt(cols) }; }; template<> struct SizedAttribute<1, 1>: SizedVectorAttribute<1> { enum class Components: GLint { One = 1 }; @@ -941,7 +951,7 @@ template<> struct Attribute> { typedef FloatAttribute::DataOption DataOption; typedef FloatAttribute::DataOptions DataOptions; - enum: UnsignedInt { VectorCount = 1 }; + enum: UnsignedInt { Vectors = 1 }; static UnsignedInt MAGNUM_GL_EXPORT size(GLint components, DataType dataType); }; diff --git a/src/Magnum/GL/Mesh.h b/src/Magnum/GL/Mesh.h index 150f5c8b3..f300ed5d1 100644 --- a/src/Magnum/GL/Mesh.h +++ b/src/Magnum/GL/Mesh.h @@ -1002,7 +1002,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { /* Computing stride of interleaved vertex attributes */ template static GLsizei strideOfInterleaved(const Attribute& attribute, const U&... attributes) { - return attribute.vectorStride()*Attribute::VectorCount + strideOfInterleaved(attributes...); + return attribute.vectorStride()*Attribute::Vectors + strideOfInterleaved(attributes...); } template static GLsizei strideOfInterleaved(GLintptr gap, const T&... attributes) { return gap + strideOfInterleaved(attributes...); @@ -1014,7 +1014,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { addVertexAttribute(buffer, attribute, offset, stride, divisor); /* Add size of this attribute to offset for next attribute */ - addVertexBufferInternal(buffer, offset+attribute.vectorStride()*Attribute::VectorCount, stride, divisor, attributes...); + addVertexBufferInternal(buffer, offset+attribute.vectorStride()*Attribute::Vectors, stride, divisor, attributes...); } template void addVertexBufferInternal(Buffer& buffer, GLintptr offset, GLsizei stride, GLuint divisor, GLintptr gap, const T&... attributes) { /* Add the gap to offset for next attribute */ @@ -1023,7 +1023,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { void addVertexBufferInternal(Buffer&, GLintptr, GLsizei, GLuint) {} template void addVertexAttribute(typename std::enable_if::ScalarType, Float>::value, Buffer&>::type buffer, const Attribute& attribute, GLintptr offset, GLsizei stride, GLuint divisor) { - for(UnsignedInt i = 0; i != Attribute::VectorCount; ++i) + for(UnsignedInt i = 0; i != Attribute::Vectors; ++i) attributePointerInternal(buffer, location+i, GLint(attribute.components()), @@ -1048,7 +1048,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { #ifndef MAGNUM_TARGET_GLES template void addVertexAttribute(typename std::enable_if::ScalarType, Double>::value, Buffer&>::type buffer, const Attribute& attribute, GLintptr offset, GLsizei stride, GLuint divisor) { - for(UnsignedInt i = 0; i != Attribute::VectorCount; ++i) + for(UnsignedInt i = 0; i != Attribute::Vectors; ++i) attributePointerInternal(buffer, location+i, GLint(attribute.components()), diff --git a/src/Magnum/GL/Test/AttributeTest.cpp b/src/Magnum/GL/Test/AttributeTest.cpp index 2b8bd9976..26cf95395 100644 --- a/src/Magnum/GL/Test/AttributeTest.cpp +++ b/src/Magnum/GL/Test/AttributeTest.cpp @@ -170,7 +170,7 @@ void AttributeTest::attributeScalar() { typedef Attribute<3, Float> Attribute; CORRADE_VERIFY((std::is_same{})); CORRADE_COMPARE(Attribute::Location, 3); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -201,7 +201,7 @@ void AttributeTest::attributeScalarInt() { #ifndef MAGNUM_TARGET_GLES2 typedef Attribute<2, Int> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -231,7 +231,7 @@ void AttributeTest::attributeScalarUnsignedInt() { #ifndef MAGNUM_TARGET_GLES2 typedef Attribute<3, UnsignedInt> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -261,7 +261,7 @@ void AttributeTest::attributeScalarDouble() { #ifndef MAGNUM_TARGET_GLES typedef Attribute<3, Double> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -280,7 +280,7 @@ void AttributeTest::attributeScalarDouble() { void AttributeTest::attributeVector() { typedef Attribute<3, Vector3> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -322,7 +322,7 @@ void AttributeTest::attributeVectorInt() { #ifndef MAGNUM_TARGET_GLES2 typedef Attribute<3, Vector2i> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -354,7 +354,7 @@ void AttributeTest::attributeVectorUnsignedInt() { #ifndef MAGNUM_TARGET_GLES2 typedef Attribute<3, Vector4ui> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -386,7 +386,7 @@ void AttributeTest::attributeVectorDouble() { #ifndef MAGNUM_TARGET_GLES typedef Attribute<3, Vector2d> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Default constructor */ Attribute a; @@ -417,7 +417,7 @@ void AttributeTest::attributeVectorDouble() { void AttributeTest::attributeVector4() { typedef Attribute<3, Vector4> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* Custom type */ #ifndef MAGNUM_TARGET_GLES @@ -454,7 +454,7 @@ void AttributeTest::attributeVectorBGRA() { #ifndef MAGNUM_TARGET_GLES typedef Attribute<3, Vector4> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 1); + CORRADE_COMPARE(Attribute::Vectors, 1); /* BGRA */ Attribute a(Attribute::Components::BGRA); @@ -473,7 +473,7 @@ void AttributeTest::attributeVectorBGRA() { void AttributeTest::attributeMatrixNxN() { typedef Attribute<3, Matrix3> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 3); + CORRADE_COMPARE(Attribute::Vectors, 3); /* Default constructor */ Attribute a; @@ -491,7 +491,7 @@ void AttributeTest::attributeMatrixNxN() { void AttributeTest::attributeMatrixNxNCustomStride() { typedef Attribute<3, Matrix3> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 3); + CORRADE_COMPARE(Attribute::Vectors, 3); /* Default stride */ Attribute a{Attribute::DataType::Short}; @@ -522,7 +522,7 @@ void AttributeTest::attributeMatrixNxNCustomStride() { void AttributeTest::attributeMatrixMxN() { typedef Attribute<3, Matrix3x4> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 3); + CORRADE_COMPARE(Attribute::Vectors, 3); /* Default constructor */ Attribute a; @@ -542,7 +542,7 @@ void AttributeTest::attributeMatrixNxNd() { #ifndef MAGNUM_TARGET_GLES typedef Attribute<3, Matrix4d> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 4); + CORRADE_COMPARE(Attribute::Vectors, 4); /* Default constructor */ Attribute a; @@ -564,7 +564,7 @@ void AttributeTest::attributeMatrixMxNd() { #ifndef MAGNUM_TARGET_GLES typedef Attribute<3, Matrix4x2d> Attribute; CORRADE_VERIFY((std::is_same{})); - CORRADE_COMPARE(Attribute::VectorCount, 4); + CORRADE_COMPARE(Attribute::Vectors, 4); /* Default constructor */ Attribute a;