Browse Source

GL: rename Attribute::VectorCount to Vectors for consistency.

Deprecated alias kept for compatibility, as usual.
pull/430/head
Vladimír Vondruš 6 years ago
parent
commit
da323625b2
  1. 3
      doc/changelog.dox
  2. 22
      src/Magnum/GL/Attribute.h
  3. 8
      src/Magnum/GL/Mesh.h
  4. 30
      src/Magnum/GL/Test/AttributeTest.cpp

3
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,

22
src/Magnum/GL/Attribute.h

@ -80,18 +80,28 @@ template<UnsignedInt location, class T> 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<T>::VectorCount
Vectors = Implementation::Attribute<T>::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<UnsignedInt location, class T> 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<std::size_t cols, std::size_t rows> struct SizedAttribute;
/* Vector attribute sizes */
template<std::size_t cols> 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<Math::Vector<4, Float>> {
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);
};

8
src/Magnum/GL/Mesh.h

@ -1002,7 +1002,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
/* Computing stride of interleaved vertex attributes */
template<UnsignedInt location, class T, class ...U> static GLsizei strideOfInterleaved(const Attribute<location, T>& attribute, const U&... attributes) {
return attribute.vectorStride()*Attribute<location, T>::VectorCount + strideOfInterleaved(attributes...);
return attribute.vectorStride()*Attribute<location, T>::Vectors + strideOfInterleaved(attributes...);
}
template<class ...T> 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<location, T>::VectorCount, stride, divisor, attributes...);
addVertexBufferInternal(buffer, offset+attribute.vectorStride()*Attribute<location, T>::Vectors, stride, divisor, attributes...);
}
template<class ...T> 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<UnsignedInt location, class T> void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::Attribute<T>::ScalarType, Float>::value, Buffer&>::type buffer, const Attribute<location, T>& attribute, GLintptr offset, GLsizei stride, GLuint divisor) {
for(UnsignedInt i = 0; i != Attribute<location, T>::VectorCount; ++i)
for(UnsignedInt i = 0; i != Attribute<location, T>::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<UnsignedInt location, class T> void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::Attribute<T>::ScalarType, Double>::value, Buffer&>::type buffer, const Attribute<location, T>& attribute, GLintptr offset, GLsizei stride, GLuint divisor) {
for(UnsignedInt i = 0; i != Attribute<location, T>::VectorCount; ++i)
for(UnsignedInt i = 0; i != Attribute<location, T>::Vectors; ++i)
attributePointerInternal(buffer,
location+i,
GLint(attribute.components()),

30
src/Magnum/GL/Test/AttributeTest.cpp

@ -170,7 +170,7 @@ void AttributeTest::attributeScalar() {
typedef Attribute<3, Float> Attribute;
CORRADE_VERIFY((std::is_same<Attribute::ScalarType, Float>{}));
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<Attribute::ScalarType, Int>{}));
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<Attribute::ScalarType, UnsignedInt>{}));
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<Attribute::ScalarType, Double>{}));
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<Attribute::ScalarType, Float>{}));
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<Attribute::ScalarType, Int>{}));
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<Attribute::ScalarType, UnsignedInt>{}));
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<Attribute::ScalarType, Double>{}));
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<Attribute::ScalarType, Float>{}));
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<Attribute::ScalarType, Float>{}));
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<Attribute::ScalarType, Float>{}));
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<Attribute::ScalarType, Float>{}));
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<Attribute::ScalarType, Float>{}));
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<Attribute::ScalarType, Double>{}));
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<Attribute::ScalarType, Double>{}));
CORRADE_COMPARE(Attribute::VectorCount, 4);
CORRADE_COMPARE(Attribute::Vectors, 4);
/* Default constructor */
Attribute a;

Loading…
Cancel
Save