]> git.tdb.fi Git - libs/gl.git/blob - source/mesh.h
Inherit Loaders from the ObjectLoader classes
[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/objectloader.h>
12 #include "batch.h"
13 #include "vertexarray.h"
14
15 namespace Msp {
16 namespace GL {
17
18 class Buffer;
19
20 class Mesh
21 {
22         friend class MeshBuilder;
23
24 public:
25         class Loader: public DataFile::ObjectLoader<Mesh>
26         {
27         public:
28                 Loader(Mesh &);
29         private:
30                 void vertices(VertexFormat);
31                 void batch(PrimitiveType);
32         };
33
34 private:
35         VertexArray vertices;
36         std::list<Batch> batches;
37         Buffer *ibuf;
38
39 public:
40         Mesh();
41         Mesh(const VertexFormat &f);
42
43         void use_vertex_buffer(bool);
44         const VertexArray &get_vertices() const { return vertices; }
45         float *get_vertex(unsigned);
46         void add_batch(const Batch &b);
47         const std::list<Batch> &get_batches() { return batches; }
48         void clear();
49         void draw() const;
50 private:
51         void update_index_buffer();
52 };
53
54 } // namespace GL
55 } // namespace Msp
56
57 #endif