X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbatch.cpp;fp=source%2Fcore%2Fbatch.cpp;h=d53156bd7a66c7bba1bc922e92aa07c4d190c30b;hb=ebef7085e2672866189ccdb3a89e977e678a89b9;hp=ebd7b049125137d2fb89f9d40255d44a139f5b8c;hpb=866c80e19e66d6dd8d49ec48d9be54a3a7fe07a2;p=libs%2Fgl.git diff --git a/source/core/batch.cpp b/source/core/batch.cpp index ebd7b049..d53156bd 100644 --- a/source/core/batch.cpp +++ b/source/core/batch.cpp @@ -1,4 +1,3 @@ -#include #include #include "batch.h" #include "buffer.h" @@ -187,54 +186,6 @@ unsigned Batch::get_index(unsigned i) const return *(UInt16 *)&data[i*sizeof(UInt16)]; } -void Batch::draw() const -{ - const void *data_ptr = setup_draw(); - glDrawElements(prim_type, size(), gl_index_type, data_ptr); -} - -void Batch::draw_instanced(unsigned count) const -{ - static Require req(ARB_draw_instanced); - - const void *data_ptr = setup_draw(); - glDrawElementsInstanced(prim_type, size(), gl_index_type, data_ptr, count); -} - -const void *Batch::setup_draw() const -{ - if(!get_buffer()) - throw invalid_operation("Batch::setup_draw"); - - if(restart) - { - unsigned index = (index_type==UNSIGNED_INT ? 0xFFFFFFFF : 0xFFFF); - - if(index!=restart_index) - set_restart_index(index); - } - else if(restart_index && restart_index<=max_index) - set_restart_index(0); - - refresh(); - - return reinterpret_cast(get_offset()); -} - -void Batch::set_restart_index(unsigned index) -{ - if(index>0) - { - if(!restart_index) - glEnable(GL_PRIMITIVE_RESTART); - glPrimitiveRestartIndex(index); - } - else - glDisable(GL_PRIMITIVE_RESTART); - - restart_index = index; -} - Batch::Loader::Loader(Batch &b): DataFile::ObjectLoader(b)