From 00fddb7f46bf0164f74a99f8f5f0081ce969260a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 30 Nov 2013 18:56:42 +0200 Subject: [PATCH] Tweak buffer logic a bit in Batch::draw Excplicitly binding the buffer first avoids unnecessary implicit binds in the buffer update code. --- source/batch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/batch.cpp b/source/batch.cpp index 34bd83c0..09a6a611 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -245,14 +245,14 @@ void Batch::draw() const restart_index = 0; } - if(get_buffer()) + if(Buffer *ibuf = get_buffer()) { + BufferAlias alias(*ibuf); + Bind bind_ibuf(alias, true); + 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 -- 2.43.0