]> git.tdb.fi Git - libs/gl.git/blob - source/meshbuilder.cpp
Add an element offset to PrimitiveBuilder
[libs/gl.git] / source / meshbuilder.cpp
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2008, 2010-2011  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "mesh.h"
9 #include "meshbuilder.h"
10
11 namespace Msp {
12 namespace GL {
13
14 MeshBuilder::MeshBuilder(Mesh &m):
15         PrimitiveBuilder(m.vertices),
16         mesh(m),
17         batch(0)
18 { }
19
20 void MeshBuilder::auto_offset()
21 {
22         offset(mesh.get_vertices().size());
23 }
24
25 void MeshBuilder::begin_()
26 {
27         batch = new Batch(type);
28 }
29
30 void MeshBuilder::end_()
31 {
32         mesh.add_batch(*batch);
33         delete batch;
34         batch = 0;
35 }
36
37 void MeshBuilder::element_(unsigned i)
38 {
39         batch->append(i);
40 }
41
42 } // namespace GL
43 } // namespace Msp