]> git.tdb.fi Git - libs/gl.git/blob - source/immediate.cpp
Generalize VertexBuffer into Buffer with support for other types as well
[libs/gl.git] / source / immediate.cpp
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 #include "immediate.h"
9
10 namespace Msp {
11 namespace GL {
12
13 Immediate::Immediate(VertexFormat f):
14         PrimitiveBuilder(array),
15         array(f)
16 { }
17
18 void Immediate::reset()
19 {
20         if(in_batch)
21                 throw InvalidState("Can't reset Immediate between begin() and end()");
22
23         array.clear();
24         indices.clear();
25 }
26
27 void Immediate::end_()
28 {
29         array.apply();
30         draw_elements(type, indices.size(), &indices[0]);
31
32         indices.clear();
33 }
34
35 void Immediate::element_(unsigned i)
36 {
37         indices.push_back(i);
38 }
39
40 } // namespace GL
41 } // namespace Msp