diff --git a/src/IndexedMesh.h b/src/IndexedMesh.h index f7ad05992..aba64e2d8 100644 --- a/src/IndexedMesh.h +++ b/src/IndexedMesh.h @@ -51,15 +51,28 @@ class MAGNUM_EXPORT IndexedMesh: public Mesh { /** @brief Index count */ inline GLsizei indexCount() const { return _indexCount; } - /** @brief Set index count */ - /** @todo definalize after that? */ - inline void setIndexCount(GLsizei count) { _indexCount = count; } + /** + * @brief Set index count + * @return Pointer to self (for method chaining) + * + * @todo definalize after that? + */ + inline IndexedMesh* setIndexCount(GLsizei count) { + _indexCount = count; + return this; + } /** @brief Index type */ inline Type indexType() const { return _indexType; } - /** @brief Set index type */ - inline void setIndexType(Type type) { _indexType = type; } + /** + * @brief Set index type + * @return Pointer to self (for method chaining) + */ + inline IndexedMesh* setIndexType(Type type) { + _indexType = type; + return this; + } /** * @brief Index buffer diff --git a/src/Mesh.h b/src/Mesh.h index 61001fcfe..a9cf40985 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -348,20 +348,28 @@ class MAGNUM_EXPORT Mesh { /** @brief Primitive type */ inline Primitive primitive() const { return _primitive; } - /** @brief Set primitive type */ - inline void setPrimitive(Primitive primitive) { _primitive = primitive; } + /** + * @brief Set primitive type + * @return Pointer to self (for method chaining) + */ + inline Mesh* setPrimitive(Primitive primitive) { + _primitive = primitive; + return this; + } /** @brief Vertex count */ inline GLsizei vertexCount() const { return _vertexCount; } /** * @brief Set vertex count + * @return Pointer to self (for method chaining) * * This forces recalculation of attribute positions upon next drawing. */ - inline void setVertexCount(GLsizei vertexCount) { + inline Mesh* setVertexCount(GLsizei vertexCount) { _vertexCount = vertexCount; finalized = false; + return this; } /** @@ -392,14 +400,16 @@ class MAGNUM_EXPORT Mesh { * @tparam attribute Attribute, defined in the shader * @param buffer Buffer where bind the attribute to (pointer * returned by addBuffer()) + * @return Pointer to self (for method chaining) * * Binds attribute of given type with given buffer. If the attribute is * already bound, given buffer isn't managed with this mesh (wasn't * initialized with addBuffer) or the mesh was already drawn, the * function does nothing. */ - template inline void bindAttribute(Buffer* buffer) { + template inline Mesh* bindAttribute(Buffer* buffer) { bindAttribute(buffer, Attribute::Location, TypeTraits::count(), TypeTraits::type()); + return this; } /**