From 12783de1ecc8c5fc5d53a23db85c655cb9bc0807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 8 Jan 2011 22:53:06 +0100 Subject: [PATCH] Allow modifying mesh vertex/index count and type. --- src/IndexedMesh.h | 6 ++++++ src/Mesh.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/IndexedMesh.h b/src/IndexedMesh.h index 94def6a36..a9c6647a9 100644 --- a/src/IndexedMesh.h +++ b/src/IndexedMesh.h @@ -44,9 +44,15 @@ class IndexedMesh: public Mesh { /** @brief Index count */ inline GLsizei indexCount() const { return _indexCount; } + /** @brief Set index count */ + inline void setIndexCount(GLsizei count) { _indexCount = count; } + /** @brief Index type */ inline GLenum indexType() const { return _indexType; } + /** @brief Set index type */ + inline void setIndexType(GLsizei type) { _indexType = type; } + /** * @brief Index buffer * diff --git a/src/Mesh.h b/src/Mesh.h index a739da0e6..7c6641364 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -94,12 +94,32 @@ class Mesh { */ virtual ~Mesh(); + /** + * @brief Whether the mesh is finalized + * + * When the mesh is finalized, no new attributes can be bound. + */ + inline bool isFinalized() const { return finalized; } + /** @brief Primitive type */ inline Primitive primitive() const { return _primitive; } + /** @brief Set primitive type */ + inline void setPrimitive(Primitive primitive) { _primitive = primitive; } + /** @brief Vertex count */ inline GLsizei vertexCount() const { return _vertexCount; } + /** + * @brief Set vertex count + * + * This forces recalculation of attribute positions upon next drawing. + */ + inline void setVertexCount(GLsizei vertexCount) { + _vertexCount = vertexCount; + finalized = false; + }; + /** * @brief Add buffer * @param interleaved If storing more than one attribute data in the @@ -166,6 +186,14 @@ class Mesh { */ void finalize(); + /** + * @brief Set the mesh dirty + * + * Sets the attribute locations in buffers as dirty, so they are + * recalculated on next drawing. + */ + inline void setDirty() { finalized = false; } + private: Primitive _primitive; GLsizei _vertexCount;