]> git.tdb.fi Git - libs/gl.git/blobdiff - source/immediate.cpp
Support multiple sets of texture coordinates in datafiles
[libs/gl.git] / source / immediate.cpp
index 8b62d2c4cc9cb6c3cee1d8b6f42a23d719490f95..15d3a634a13248063efd29c2f5889fff7110c120 100644 (file)
@@ -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();
-       glDrawElements(type, indices.size(), UNSIGNED_INT, &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);