X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fimmediate.cpp;h=cf1be08ed7204209d0d572b851ce76b7c58469ff;hp=8b62d2c4cc9cb6c3cee1d8b6f42a23d719490f95;hb=944deb38084e5e5bc82182faab2db2be156b971c;hpb=0f3ae7cf6aed59f07895dfbef6740be3b666fc20 diff --git a/source/immediate.cpp b/source/immediate.cpp index 8b62d2c4..cf1be08e 100644 --- a/source/immediate.cpp +++ b/source/immediate.cpp @@ -1,10 +1,5 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include "batch.h" +#include "error.h" #include "immediate.h" namespace Msp { @@ -13,17 +8,31 @@ namespace GL { Immediate::Immediate(VertexFormat f): PrimitiveBuilder(array), array(f) -{ } +{ + array.use_buffer(0); +} -void Immediate::end_() +void Immediate::reset() { - array.apply(); - glDrawElements(type, indices.size(), UNSIGNED_INT, &indices[0]); + if(in_batch) + throw invalid_operation("Immediate::reset"); 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);