-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include "mesh.h"
#include "meshbuilder.h"
MeshBuilder::MeshBuilder(Mesh &m):
PrimitiveBuilder(m.vertices),
mesh(m),
- first(0)
+ batch(0)
{ }
+MeshBuilder::~MeshBuilder()
+{
+ mesh.check_buffers(Mesh::VERTEX_BUFFER);
+}
+
+void MeshBuilder::auto_offset()
+{
+ offset(mesh.get_vertices().size());
+}
+
void MeshBuilder::begin_()
{
- first=array.size();
+ batch = new Batch(type);
}
void MeshBuilder::end_()
{
- Batch batch(type);
- unsigned last=array.size();
- for(unsigned i=first; i<last; ++i)
- batch.append(i);
- mesh.add_batch(batch);
+ mesh.add_batch(*batch);
+ delete batch;
+ batch = 0;
+}
+
+void MeshBuilder::element_(unsigned i)
+{
+ batch->append(i);
}
} // namespace GL