]> git.tdb.fi Git - libs/gl.git/blob - source/mesh.h
Drop Id tags and copyright notices from files
[libs/gl.git] / source / mesh.h
1 #ifndef MSP_GL_MESH_H_
2 #define MSP_GL_MESH_H_
3
4 #include <msp/datafile/objectloader.h>
5 #include "batch.h"
6 #include "vertexarray.h"
7 #include "windingtest.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class Buffer;
13 class Renderer;
14
15 class Mesh
16 {
17         friend class MeshBuilder;
18
19 public:
20         class Loader: public DataFile::ObjectLoader<Mesh>
21         {
22         public:
23                 Loader(Mesh &);
24         private:
25                 void vertices(VertexFormat);
26                 void batch(PrimitiveType);
27                 void winding(FaceWinding);
28         };
29
30 private:
31         VertexArray vertices;
32         std::list<Batch> batches;
33         Buffer *ibuf;
34         bool defer_ibuf;
35         const WindingTest *winding;
36
37 public:
38         Mesh();
39         Mesh(const VertexFormat &f);
40         ~Mesh();
41
42         void clear();
43         void use_buffers(bool);
44
45         const VertexArray &get_vertices() const { return vertices; }
46         unsigned get_n_vertices() const;
47         float *modify_vertex(unsigned);
48
49         void add_batch(const Batch &b);
50         const std::list<Batch> &get_batches() { return batches; }
51
52         void set_winding(const WindingTest *);
53
54         void draw() const;
55         void draw(Renderer &) const;
56 };
57
58 } // namespace GL
59 } // namespace Msp
60
61 #endif