]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove vertex array tracking from Renderer
authorMikko Rasa <tdb@tdb.fi>
Fri, 29 Nov 2013 08:46:27 +0000 (10:46 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 29 Nov 2013 09:33:25 +0000 (11:33 +0200)
It's unnecessary because VertexArray has its own state tracking and never
needs to be unbound.

source/mesh.cpp
source/renderer.cpp
source/renderer.h

index 281bb7c2c9c67a01c2507e63565779e11701bfa4..07eaa68962a8952da9c4fa3f3e482a85c55d90dc 100644 (file)
@@ -110,7 +110,7 @@ void Mesh::draw() const
 
 void Mesh::draw(Renderer &renderer) const
 {
-       renderer.set_vertex_array(&vertices);
+       vertices.apply();
        renderer.set_element_buffer(ibuf);
        renderer.set_winding_test(winding);
 
index c56216edf0fe88950a251949ea0ace70664429c6..8199d3a64dc4056c3e621a3cc46b909c5d1d0f66 100644 (file)
@@ -24,7 +24,6 @@ Renderer::Renderer(const Camera *c):
        camera(c),
        state_stack(1),
        lighting_changed(false),
-       vertex_array(0),
        element_buffer(0)
 {
        state_stack.reserve(16);
@@ -99,11 +98,6 @@ void Renderer::add_shader_data(const ProgramData &d)
        shdata_changed = true;
 }
 
-void Renderer::set_vertex_array(const VertexArray *a)
-{
-       vertex_array = a;
-}
-
 void Renderer::set_element_buffer(const Buffer *b)
 {
        element_buffer = b;
@@ -164,13 +158,8 @@ void Renderer::render(const Renderable &renderable, const Tag &tag)
 
 void Renderer::draw(const Batch &batch)
 {
-       if(!vertex_array)
-               throw invalid_operation("Renderer::draw");
-
        apply_state();
 
-       vertex_array->apply();
-
        if(element_buffer)
                element_buffer->bind_to(ELEMENT_ARRAY_BUFFER);
        else
index a4663df87a152d3a0444e48b42e97558e49f2bab..a45b2943004d0beb96c654ad0f6796de4b673e3a 100644 (file)
@@ -19,7 +19,6 @@ class ProgramData;
 class Renderable;
 class Texture;
 class Texturing;
-class VertexArray;
 class WindingTest;
 
 /**
@@ -95,7 +94,6 @@ private:
        bool lighting_changed;
        std::vector<const ProgramData *> shdata_stack;
        bool shdata_changed;
-       const VertexArray *vertex_array;
        const Buffer *element_buffer;
        std::set<const Renderable *> excluded;
 
@@ -122,7 +120,6 @@ public:
        Renderer state is popped. */
        void add_shader_data(const ProgramData &data);
 
-       void set_vertex_array(const VertexArray *);
        void set_element_buffer(const Buffer *);
        void set_winding_test(const WindingTest *);
        void set_reverse_winding(bool);