]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderer.cpp
Remove separate element_buffer from Renderer, get it from mesh instead
[libs/gl.git] / source / renderer.cpp
index 2d262e73bef495501afa333f6e5601a93468a9ac..bc49b0f802941f3ae2a7509ae86351dc51a67ca8 100644 (file)
@@ -26,8 +26,7 @@ Renderer::Renderer(const Camera *c):
        matrices_loaded(false),
        shdata_applied(0),
        camera(0),
-       state_stack(1),
-       element_buffer(0)
+       state_stack(1)
 {
        state_stack.reserve(16);
        shdata_stack.reserve(32);
@@ -112,11 +111,6 @@ void Renderer::set_mesh(const Mesh *m)
        state->mesh = m;
 }
 
-void Renderer::set_element_buffer(const Buffer *b)
-{
-       element_buffer = b;
-}
-
 void Renderer::set_winding_test(const WindingTest *w)
 {
        state->winding_test = w;
@@ -203,10 +197,10 @@ void Renderer::draw(const Batch &batch)
        apply_state();
 
        bool legacy_bindings = (!state->shprog || state->shprog->uses_legacy_variables());
-       if(legacy_bindings)
+       if(state->mesh && legacy_bindings)
        {
-               if(element_buffer)
-                       element_buffer->bind_to(ELEMENT_ARRAY_BUFFER);
+               if(const Buffer *ibuf = state->mesh->get_index_buffer())
+                       ibuf->bind_to(ELEMENT_ARRAY_BUFFER);
                else
                        Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
        }