]> git.tdb.fi Git - libs/gl.git/blob - source/mesh.cpp
Add mult_matrix functions
[libs/gl.git] / source / mesh.cpp
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "mesh.h"
9
10 using namespace std;
11
12 namespace Msp {
13 namespace GL {
14
15 Mesh::Mesh():
16         vertices(NODATA)
17 {
18         vertices.use_vertex_buffer();
19 }
20
21 void Mesh::draw() const
22 {
23         vertices.apply();
24         for(list<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
25                 i->draw();
26 }
27
28
29 Mesh::Loader::Loader(Mesh &m):
30         mesh(m)
31 {
32         add("vertices", &Loader::vertices);
33         add("batch",    &Loader::batch);
34 }
35
36 void Mesh::Loader::vertices(VertexFormat f)
37 {
38         mesh.vertices.reset(f);
39         load_sub(mesh.vertices);
40 }
41
42 void Mesh::Loader::batch(PrimitiveType p)
43 {
44         mesh.batches.push_back(Batch(p));
45         load_sub(mesh.batches.back());
46 }
47
48 } // namespace GL
49 } // namespace Msp