]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderer.cpp
Some refactoring of the draw code path
[libs/gl.git] / source / renderer.cpp
index e59949a3683f938797251a4a5d3f34a7ebbddc46..53a3f45237463e5fffed3e084805326453e5fd3a 100644 (file)
@@ -269,15 +269,6 @@ 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();
 }
 
@@ -386,6 +377,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();