Browse Source

Method chaining for Mesh.

pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
02f0de619a
  1. 23
      src/IndexedMesh.h
  2. 18
      src/Mesh.h

23
src/IndexedMesh.h

@ -51,15 +51,28 @@ class MAGNUM_EXPORT IndexedMesh: public Mesh {
/** @brief Index count */ /** @brief Index count */
inline GLsizei indexCount() const { return _indexCount; } inline GLsizei indexCount() const { return _indexCount; }
/** @brief Set index count */ /**
/** @todo definalize after that? */ * @brief Set index count
inline void setIndexCount(GLsizei count) { _indexCount = count; } * @return Pointer to self (for method chaining)
*
* @todo definalize after that?
*/
inline IndexedMesh* setIndexCount(GLsizei count) {
_indexCount = count;
return this;
}
/** @brief Index type */ /** @brief Index type */
inline Type indexType() const { return _indexType; } 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 * @brief Index buffer

18
src/Mesh.h

@ -348,20 +348,28 @@ class MAGNUM_EXPORT Mesh {
/** @brief Primitive type */ /** @brief Primitive type */
inline Primitive primitive() const { return _primitive; } 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 */ /** @brief Vertex count */
inline GLsizei vertexCount() const { return _vertexCount; } inline GLsizei vertexCount() const { return _vertexCount; }
/** /**
* @brief Set vertex count * @brief Set vertex count
* @return Pointer to self (for method chaining)
* *
* This forces recalculation of attribute positions upon next drawing. * This forces recalculation of attribute positions upon next drawing.
*/ */
inline void setVertexCount(GLsizei vertexCount) { inline Mesh* setVertexCount(GLsizei vertexCount) {
_vertexCount = vertexCount; _vertexCount = vertexCount;
finalized = false; finalized = false;
return this;
} }
/** /**
@ -392,14 +400,16 @@ class MAGNUM_EXPORT Mesh {
* @tparam attribute Attribute, defined in the shader * @tparam attribute Attribute, defined in the shader
* @param buffer Buffer where bind the attribute to (pointer * @param buffer Buffer where bind the attribute to (pointer
* returned by addBuffer()) * returned by addBuffer())
* @return Pointer to self (for method chaining)
* *
* Binds attribute of given type with given buffer. If the attribute is * Binds attribute of given type with given buffer. If the attribute is
* already bound, given buffer isn't managed with this mesh (wasn't * already bound, given buffer isn't managed with this mesh (wasn't
* initialized with addBuffer) or the mesh was already drawn, the * initialized with addBuffer) or the mesh was already drawn, the
* function does nothing. * function does nothing.
*/ */
template<class Attribute> inline void bindAttribute(Buffer* buffer) { template<class Attribute> inline Mesh* bindAttribute(Buffer* buffer) {
bindAttribute(buffer, Attribute::Location, TypeTraits<typename Attribute::Type>::count(), TypeTraits<typename Attribute::Type>::type()); bindAttribute(buffer, Attribute::Location, TypeTraits<typename Attribute::Type>::count(), TypeTraits<typename Attribute::Type>::type());
return this;
} }
/** /**

Loading…
Cancel
Save