]> git.tdb.fi Git - libs/gl.git/blob - source/immediate.cpp
Restore old buffer binding when setting data
[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         array.use_vertex_buffer(0);
18 }
19
20 void Immediate::reset()
21 {
22         if(in_batch)
23                 throw InvalidState("Can't reset Immediate between begin() and end()");
24
25         array.clear();
26         indices.clear();
27 }
28
29 void Immediate::end_()
30 {
31         array.apply();
32         draw_elements(type, indices.size(), &indices[0]);
33
34         indices.clear();
35 }
36
37 void Immediate::element_(unsigned i)
38 {
39         indices.push_back(i);
40 }
41
42 } // namespace GL
43 } // namespace Msp