X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fimmediate.cpp;h=15d3a634a13248063efd29c2f5889fff7110c120;hb=c48cb5362edb16c33ed5f6862a908bb9a754c85a;hp=e12ac9b53ca01ec2b3d9b73a86898605d60c724d;hpb=dc1d1159a61f378bda11e5989ad694a86b9a3c77;p=libs%2Fgl.git diff --git a/source/immediate.cpp b/source/immediate.cpp index e12ac9b5..15d3a634 100644 --- a/source/immediate.cpp +++ b/source/immediate.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include "batch.h" #include "immediate.h" namespace Msp { @@ -13,17 +14,31 @@ namespace GL { Immediate::Immediate(VertexFormat f): PrimitiveBuilder(array), array(f) -{ } +{ + array.use_vertex_buffer(0); +} -void Immediate::end_() +void Immediate::reset() { - array.apply(); - draw_elements(type, indices.size(), &indices[0]); + if(in_batch) + throw InvalidState("Can't reset Immediate between begin() and end()"); array.clear(); +} + +void Immediate::begin_() +{ indices.clear(); } +void Immediate::end_() +{ + Batch batch(type); + batch.append(indices); + array.apply(); + batch.draw(); +} + void Immediate::element_(unsigned i) { indices.push_back(i);