]> git.tdb.fi Git - libs/gl.git/commitdiff
Tweak buffer logic a bit in Batch::draw
authorMikko Rasa <tdb@tdb.fi>
Sat, 30 Nov 2013 16:56:42 +0000 (18:56 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 30 Nov 2013 16:56:42 +0000 (18:56 +0200)
Excplicitly binding the buffer first avoids unnecessary implicit binds in
the buffer update code.

source/batch.cpp

index 34bd83c0d7ac07683bc3bea118c9d33a46f3e012..09a6a6111314262d57b7607939da42a74ecc3f89 100644 (file)
@@ -245,14 +245,14 @@ void Batch::draw() const
                restart_index = 0;
        }
 
-       if(get_buffer())
+       if(Buffer *ibuf = get_buffer())
        {
+               BufferAlias<ELEMENT_ARRAY_BUFFER> alias(*ibuf);
+               Bind bind_ibuf(alias, true);
+
                if(dirty)
                        update_buffer();
 
-               BufferAlias<ELEMENT_ARRAY_BUFFER> alias(*get_buffer());
-               Bind bind_ibuf(alias, true);
-
                glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, reinterpret_cast<void *>(get_offset()));
        }
        else