]> git.tdb.fi Git - libs/gl.git/blob - source/primitivebuilder.h
b8b90f44f081391e08f1378cd8517cf800a7231c
[libs/gl.git] / source / primitivebuilder.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2008, 2010-2011  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_PRIMITIVEBUILDER_H_
9 #define MSP_GL_PRIMITIVEBUILDER_H_
10
11 #include "primitivetype.h"
12 #include "vertexarray.h"
13 #include "vertexbuilder.h"
14
15 namespace Msp {
16 namespace GL {
17
18 class VertexArray;
19 class VertexArrayBuilder;
20
21 /**
22 Base class for primitive builders.  This is derived from VertexBuilder and adds
23 begin() and end() functions for specifying batches of primitives instead of
24 just vertices.
25 */
26 class PrimitiveBuilder: public VertexBuilder
27 {
28 protected:
29         VertexArray &array;
30         VertexArrayBuilder vab;
31         PrimitiveType type;
32         bool in_batch;
33         unsigned offs;
34
35         PrimitiveBuilder(VertexArray &);
36 public:
37         void begin(PrimitiveType);
38         void end();
39         void offset(unsigned);
40         void element(unsigned);
41         PrimitiveType get_type() const;
42 protected:
43         virtual void vertex_(const Vector4 &);
44         virtual void begin_() =0;
45         virtual void end_() =0;
46         virtual void element_(unsigned) =0;
47 };
48
49 } // namespace GL
50 } // namespace Msp
51
52 #endif