]> git.tdb.fi Git - libs/gl.git/blob - source/immediate.cpp
15d3a634a13248063efd29c2f5889fff7110c120
[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 "batch.h"
9 #include "immediate.h"
10
11 namespace Msp {
12 namespace GL {
13
14 Immediate::Immediate(VertexFormat f):
15         PrimitiveBuilder(array),
16         array(f)
17 {
18         array.use_vertex_buffer(0);
19 }
20
21 void Immediate::reset()
22 {
23         if(in_batch)
24                 throw InvalidState("Can't reset Immediate between begin() and end()");
25
26         array.clear();
27 }
28
29 void Immediate::begin_()
30 {
31         indices.clear();
32 }
33
34 void Immediate::end_()
35 {
36         Batch batch(type);
37         batch.append(indices);
38         array.apply();
39         batch.draw();
40 }
41
42 void Immediate::element_(unsigned i)
43 {
44         indices.push_back(i);
45 }
46
47 } // namespace GL
48 } // namespace Msp