X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbatch.cpp;h=7f9adff7aad42ca8a9cb8e3bd4758ff2048acb75;hb=8b99547d099c96bd8cc6037e2026db123b2523c1;hp=3f7bffee901da3bfab572e197a44da13ff912741;hpb=15f4fded5d6d2a5f22e41e50891e783c026688c0;p=libs%2Fgl.git diff --git a/source/batch.cpp b/source/batch.cpp index 3f7bffee..7f9adff7 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -1,9 +1,10 @@ +#include +#include #include "batch.h" #include "bindable.h" #include "buffer.h" #include "error.h" -#include "ext_draw_range_elements.h" -#include "nv_primitive_restart.h" +#include "mesh.h" #include "vertexarray.h" using namespace std; @@ -97,7 +98,7 @@ void Batch::set_data_type(DataType t) Batch &Batch::append(unsigned i) { append_index(i); - + update_offset(); dirty = true; @@ -117,6 +118,16 @@ void Batch::append(const vector &ind) dirty = true; } +bool Batch::can_append(PrimitiveType other_type) +{ + if(other_type!=prim_type) + return false; + else if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN || prim_type==POLYGON) + return NV_primitive_restart; + else + return true; +} + void Batch::append(const Batch &other) { if(other.prim_type!=prim_type) @@ -235,14 +246,13 @@ void Batch::draw() const restart_index = 0; } - if(get_buffer()) + if(Buffer *ibuf = get_buffer()) { + BindRestore _bind_ibuf(ibuf, ELEMENT_ARRAY_BUFFER); + if(dirty) update_buffer(); - BufferAlias alias(*get_buffer()); - Bind bind_ibuf(alias, true); - glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, reinterpret_cast(get_offset())); } else