]> git.tdb.fi Git - libs/gl.git/blob - source/mesh.h
Add append() method and and operator[] to VertexArray
[libs/gl.git] / source / mesh.h
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 #ifndef MSP_GL_MESH_H_
9 #define MSP_GL_MESH_H_
10
11 #include <msp/datafile/loader.h>
12 #include "batch.h"
13 #include "vertexarray.h"
14
15 namespace Msp {
16 namespace GL {
17
18 class Mesh
19 {
20         friend class MeshBuilder;
21
22 public:
23         class Loader: public DataFile::Loader
24         {
25         public:
26                 Loader(Mesh &);
27         private:
28                 Mesh &mesh;
29
30                 void vertices(VertexFormat);
31                 void batch(PrimitiveType);
32         };
33
34 private:
35         VertexArray vertices;
36         std::list<Batch> batches;
37
38 public:
39         Mesh();
40         Mesh(VertexFormat f);
41
42         void use_vertex_buffer(bool);
43         const VertexArray &get_vertices() const { return vertices; }
44         void add_batch(const Batch &b);
45         const std::list<Batch> &get_batches() { return batches; }
46         void draw() const;
47 };
48
49 } // namespace GL
50 } // namespace Msp
51
52 #endif