X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fbatch.cpp;h=bca33484ce976cc585d8da88187c8ba568baed23;hp=09a6a6111314262d57b7607939da42a74ecc3f89;hb=c233a90fd05f1f5424d7fca94bb6b999f3061271;hpb=5c51ba1057b222ab44eca253828d58e107e80df0 diff --git a/source/batch.cpp b/source/batch.cpp index 09a6a611..bca33484 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -4,6 +4,7 @@ #include "bindable.h" #include "buffer.h" #include "error.h" +#include "mesh.h" #include "vertexarray.h" using namespace std; @@ -247,13 +248,25 @@ void Batch::draw() const if(Buffer *ibuf = get_buffer()) { - BufferAlias alias(*ibuf); - Bind bind_ibuf(alias, true); + bool have_vao = Mesh::current(); + const Buffer *old_ibuf = 0; + if(!have_vao) + { + old_ibuf = Buffer::current(ELEMENT_ARRAY_BUFFER); + ibuf->bind_to(ELEMENT_ARRAY_BUFFER); + } if(dirty) update_buffer(); glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, reinterpret_cast(get_offset())); + if(!have_vao) + { + if(old_ibuf) + old_ibuf->bind_to(ELEMENT_ARRAY_BUFFER); + else + Buffer::unbind_from(ELEMENT_ARRAY_BUFFER); + } } else glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, &data[0]);