]> git.tdb.fi Git - libs/gl.git/blobdiff - source/immediate.cpp
Keep track of which components have been set in Transform
[libs/gl.git] / source / immediate.cpp
index e12ac9b53ca01ec2b3d9b73a86898605d60c724d..cf1be08ed7204209d0d572b851ce76b7c58469ff 100644 (file)
@@ -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();
-       draw_elements(type, indices.size(), &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);