]> git.tdb.fi Git - libs/gl.git/blobdiff - source/batch.cpp
Add object-oriented interfaces for the various tests and blending
[libs/gl.git] / source / batch.cpp
index 385b4697085f6215e075344ac9a980007212e193..9ed20a1f524dc5d334c2825a8867f77cc8ea31f5 100644 (file)
@@ -7,7 +7,7 @@ Distributed under the LGPL
 
 #include "batch.h"
 #include "extension.h"
-#include "version_1_2.h"
+#include "vertexarray.h"
 
 using namespace std;
 
@@ -18,11 +18,9 @@ Batch::Batch(PrimitiveType t):
        type(t),
        min_index(0),
        max_index(0)
-{
-       require_version(1, 2);
-}
+{ }
 
-Batch &Batch::append(uint i)
+Batch &Batch::append(unsigned i)
 {
        if(indices.empty())
                min_index=max_index=i;
@@ -36,28 +34,33 @@ Batch &Batch::append(uint i)
        return *this;
 }
 
-void Batch::append(const vector<uint> &ind)
+void Batch::append(const vector<unsigned> &ind)
 {
        indices.reserve(indices.size()+ind.size());
-       for(vector<uint>::const_iterator i=ind.begin(); i!=ind.end(); ++i)
+       for(vector<unsigned>::const_iterator i=ind.begin(); i!=ind.end(); ++i)
                append(*i);
 }
 
 void Batch::draw() const
 {
-       glDrawRangeElements(type, min_index, max_index, indices.size(), GL_UNSIGNED_INT, &indices[0]);
+       draw_range_elements(type, min_index, max_index, indices.size(), &indices[0]);
+}
+
+void Batch::draw_with_buffer(unsigned offset) const
+{
+       draw_range_elements(type, min_index, max_index, indices.size(), (unsigned *)0+offset);
 }
 
 
 Batch::Loader::Loader(Batch &b):
-       batch(b)
+       DataFile::ObjectLoader<Batch>(b)
 {
        add("indices", &Loader::indices);
 }
 
-void Batch::Loader::indices(const vector<uint> &ind)
+void Batch::Loader::indices(const vector<unsigned> &ind)
 {
-       batch.append(ind);
+       obj.append(ind);
 }
 
 } // namespace GL