X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fimmediate.cpp;h=cbcc37b9e7d17490f355ec5ca2c2601cce27a811;hb=db735acce6c9409fabcab80d87930263032af47c;hp=8e761f4329c4c5cec8921d62753849fb5ff98e2d;hpb=d1800d7ea80290f4913d0203241cef1409656522;p=libs%2Fgl.git diff --git a/source/immediate.cpp b/source/immediate.cpp index 8e761f43..cbcc37b9 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,14 +8,34 @@ namespace GL { Immediate::Immediate(VertexFormat f): PrimitiveBuilder(array), array(f) -{ } +{ + array.use_vertex_buffer(0); +} + +void Immediate::reset() +{ + 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(); - glDrawArrays(type, 0, array.size()); + batch.draw(); +} - array.clear(); +void Immediate::element_(unsigned i) +{ + indices.push_back(i); } } // namespace GL