X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbatch.cpp;h=86ad9435fd29b2072581a73d72df9ab5c10c98ea;hb=12ac9bec8e03029c1042fd7732a2cfc04c9a9584;hp=d650fda8b6c3576cf3605d0f632f4d0faf17200f;hpb=f71aee8c20ff85e4857e4dfad0c20ce606ea3717;p=libs%2Fgl.git diff --git a/source/batch.cpp b/source/batch.cpp index d650fda8..86ad9435 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -5,8 +5,9 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#define GL_GLEXT_PROTOTYPES #include "batch.h" +#include "extension.h" +#include "vertexarray.h" using namespace std; @@ -19,40 +20,47 @@ Batch::Batch(PrimitiveType t): max_index(0) { } -void Batch::append(uint i) +Batch &Batch::append(unsigned i) { if(indices.empty()) - min_index=max_index=i; + min_index = max_index = i; else { - min_index=min(min_index, i); - max_index=max(max_index, i); + min_index = min(min_index, i); + max_index = max(max_index, i); } indices.push_back(i); + + return *this; } -void Batch::append(const vector &ind) +void Batch::append(const vector &ind) { indices.reserve(indices.size()+ind.size()); - for(vector::const_iterator i=ind.begin(); i!=ind.end(); ++i) + for(vector::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(b) { add("indices", &Loader::indices); } -void Batch::Loader::indices(const vector &ind) +void Batch::Loader::indices(const vector &ind) { - batch.append(ind); + obj.append(ind); } } // namespace GL