]> git.tdb.fi Git - libs/gl.git/blob - source/mesh.h
Support different data types in Batch
[libs/gl.git] / source / mesh.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007-2010  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         bool defer_ibuf;
39
40 public:
41         Mesh();
42         Mesh(const VertexFormat &f);
43         ~Mesh();
44
45         void clear();
46         void use_buffers(bool);
47
48         const VertexArray &get_vertices() const { return vertices; }
49         unsigned get_n_vertices() const;
50         float *modify_vertex(unsigned);
51
52         void add_batch(const Batch &b);
53         const std::list<Batch> &get_batches() { return batches; }
54
55         void draw() const;
56 };
57
58 } // namespace GL
59 } // namespace Msp
60
61 #endif