From bba295bd3dc4d12b9513a46a4decd23f03f45bcb Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 15 Jan 2011 22:10:00 +0000 Subject: [PATCH] Avoid having an empty "null" chunk --- src/Mesh.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 02366f9..69f8395 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -90,8 +90,7 @@ struct MeshBuffer : IMeshBuffer { MeshBuffer::MeshBuffer() : reused(0) { - // Create an initial chunk for the null texture - bind(ITexturePtr()); + } void MeshBuffer::bind(ITexturePtr tex) @@ -188,6 +187,11 @@ void MeshBuffer::add(const Vertex& vertex, const Colour& colour, const TexCoord& a_tex_coord) { + if (!active_chunk) { + // Create an initial chunk for the null texture + bind(ITexturePtr()); + } + // See if this vertex has already been added for (vector::iterator it = active_chunk->indices.begin(); it != active_chunk->indices.end(); ++it) { -- 2.39.2