]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove separate element_buffer from Renderer, get it from mesh instead
authorMikko Rasa <tdb@tdb.fi>
Sat, 1 Nov 2014 00:26:34 +0000 (02:26 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 1 Nov 2014 00:26:34 +0000 (02:26 +0200)
source/mesh.cpp
source/renderer.cpp
source/renderer.h

index d1cb77f143c7a1ede2e5873fc1a21bb6c331d568..301c00f94b331fc6c87087bc9f79a8b558c675a0 100644 (file)
@@ -170,7 +170,6 @@ void Mesh::draw(Renderer &renderer) const
        }
 
        renderer.set_mesh(this);
-       renderer.set_element_buffer(ibuf);
        renderer.set_winding_test(winding);
 
        for(list<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
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);
        }
index 1f198dae7007b00db30d4c699f0832ce06d0cca1..10d1fb3f13c0f2c2f8d9b539a5b90d724d72b506 100644 (file)
@@ -107,7 +107,6 @@ private:
        State *state;
        ProgramData standard_shdata;
        std::vector<const ProgramData *> shdata_stack;
-       const Buffer *element_buffer;
        std::set<const Renderable *> excluded;
 
 public:
@@ -140,7 +139,6 @@ public:
        void add_shader_data(const ProgramData &data);
 
        void set_mesh(const Mesh *);
-       void set_element_buffer(const Buffer *);
        void set_winding_test(const WindingTest *);
        void set_reverse_winding(bool);