From 8aea0f65f9ab7d603e47cf4479388af246cc8400 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 29 Nov 2013 10:46:27 +0200 Subject: [PATCH] Remove vertex array tracking from Renderer It's unnecessary because VertexArray has its own state tracking and never needs to be unbound. --- source/mesh.cpp | 2 +- source/renderer.cpp | 11 ----------- source/renderer.h | 3 --- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/source/mesh.cpp b/source/mesh.cpp index 281bb7c2..07eaa689 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -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); diff --git a/source/renderer.cpp b/source/renderer.cpp index c56216ed..8199d3a6 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -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 diff --git a/source/renderer.h b/source/renderer.h index a4663df8..a45b2943 100644 --- a/source/renderer.h +++ b/source/renderer.h @@ -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 shdata_stack; bool shdata_changed; - const VertexArray *vertex_array; const Buffer *element_buffer; std::set 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); -- 2.45.2