]> git.tdb.fi Git - libs/gl.git/blob - source/immediate.cpp
Use a renderer in the viewer
[libs/gl.git] / source / immediate.cpp
1 #include "batch.h"
2 #include "error.h"
3 #include "immediate.h"
4
5 namespace Msp {
6 namespace GL {
7
8 Immediate::Immediate(VertexFormat f):
9         PrimitiveBuilder(array),
10         array(f)
11 {
12         array.use_buffer(0);
13 }
14
15 void Immediate::reset()
16 {
17         if(in_batch)
18                 throw invalid_operation("Immediate::reset");
19
20         array.clear();
21 }
22
23 void Immediate::begin_()
24 {
25         indices.clear();
26 }
27
28 void Immediate::end_()
29 {
30         Batch batch(type);
31         batch.append(indices);
32         array.apply();
33         batch.draw();
34 }
35
36 void Immediate::element_(unsigned i)
37 {
38         indices.push_back(i);
39 }
40
41 } // namespace GL
42 } // namespace Msp