diff --git a/src/IndexedMesh.cpp b/src/IndexedMesh.cpp index 4674427a1..240f547db 100644 --- a/src/IndexedMesh.cpp +++ b/src/IndexedMesh.cpp @@ -15,7 +15,10 @@ #include "IndexedMesh.h" +#include + using namespace std; +using namespace Corrade::Utility; namespace Magnum { @@ -48,4 +51,13 @@ void IndexedMesh::draw() { glDisableVertexAttribArray(*it); } +void IndexedMesh::finalize() { + if(!_indexCount) { + Error() << "IndexedMesh: the mesh has zero index count!"; + assert(0); + } + + Mesh::finalize(); +} + } diff --git a/src/IndexedMesh.h b/src/IndexedMesh.h index 9eb984fdc..a55422a10 100644 --- a/src/IndexedMesh.h +++ b/src/IndexedMesh.h @@ -76,6 +76,9 @@ class MAGNUM_EXPORT IndexedMesh: public Mesh { */ void draw(); + protected: + void finalize(); + private: Buffer _indexBuffer; GLsizei _indexCount; diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 432372492..1030ad6a7 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -16,9 +16,11 @@ #include "Mesh.h" #include "Buffer.h" +#include #include using namespace std; +using namespace Corrade::Utility; namespace Magnum { @@ -68,6 +70,11 @@ void Mesh::finalize() { /* Already finalized */ if(finalized) return; + if(!_vertexCount) { + Error() << "Mesh: the mesh has zero vertex count!"; + assert(0); + } + /* Finalize attribute positions for every buffer */ for(map > >::iterator it = _buffers.begin(); it != _buffers.end(); ++it) { /* Avoid confustion */ diff --git a/src/Mesh.h b/src/Mesh.h index e97e0e7b4..5a2c83dc4 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -214,7 +214,7 @@ class MAGNUM_EXPORT Mesh { * Computes location and stride of each attribute in its buffer. After * this function is called, no new attribute can be bound. */ - void finalize(); + virtual void finalize(); /** * @brief Set the mesh dirty