]> git.tdb.fi Git - libs/gl.git/blob - source/mesh.h
Lots of comment updates
[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 /**
16 Raw mesh data, consisting of a VertexArray and one or more Batches.  Though a
17 Mesh can draw itself, it's usually used as part of Renderables rather than on
18 its own.
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                 void winding(FaceWinding);
33         };
34
35 private:
36         VertexArray vertices;
37         std::list<Batch> batches;
38         Buffer *ibuf;
39         bool defer_ibuf;
40         const WindingTest *winding;
41
42 public:
43         Mesh();
44         Mesh(const VertexFormat &f);
45         ~Mesh();
46
47         void clear();
48         void use_buffers(bool);
49
50         const VertexArray &get_vertices() const { return vertices; }
51         unsigned get_n_vertices() const;
52         float *modify_vertex(unsigned);
53
54         void add_batch(const Batch &b);
55         const std::list<Batch> &get_batches() { return batches; }
56
57         void set_winding(const WindingTest *);
58
59         void draw() const;
60         void draw(Renderer &) const;
61 };
62
63 } // namespace GL
64 } // namespace Msp
65
66 #endif