X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frenderer.cpp;h=cc00ac8e3affda145ec8e2f8afcc5c1d7bb4af40;hp=e59949a3683f938797251a4a5d3f34a7ebbddc46;hb=56beca9d8b4f7b4edac81411d31e24df88e84ac3;hpb=463746f62d9b48f9fbbba3b2fcf7354067873e94 diff --git a/source/renderer.cpp b/source/renderer.cpp index e59949a3..cc00ac8e 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -269,18 +269,16 @@ void Renderer::draw(const Batch &batch) { apply_state(); - bool legacy_bindings = (!state->shprog || state->shprog->uses_legacy_variables()); - if(state->mesh && legacy_bindings) - { - if(const Buffer *ibuf = state->mesh->get_index_buffer()) - ibuf->bind_to(ELEMENT_ARRAY_BUFFER); - else - Buffer::unbind_from(ELEMENT_ARRAY_BUFFER); - } - batch.draw(); } +void Renderer::draw_instanced(const Batch &batch, unsigned count) +{ + apply_state(); + + batch.draw_instanced(count); +} + void Renderer::apply_state() { /* We (mostly) let the objects themselves figure out if the binding has @@ -386,6 +384,10 @@ void Renderer::apply_state() { Mesh::unbind(); state->mesh->get_vertices().apply(); + if(const Buffer *ibuf = state->mesh->get_index_buffer()) + ibuf->bind_to(ELEMENT_ARRAY_BUFFER); + else + Buffer::unbind_from(ELEMENT_ARRAY_BUFFER); } else state->mesh->bind();