]> git.tdb.fi Git - libs/gl.git/blobdiff - source/meshbuilder.cpp
Convert svn:ignore to .gitignore
[libs/gl.git] / source / meshbuilder.cpp
index cd3be666780285da52c0adfff0e69cd1b0833319..6f90f67de40cd9940dd381727b9a592b0876582b 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2008, 2010-2011  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -14,21 +14,29 @@ namespace GL {
 MeshBuilder::MeshBuilder(Mesh &m):
        PrimitiveBuilder(m.vertices),
        mesh(m),
-       first(0)
+       batch(0)
 { }
 
+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