From ff458d6c6118f3864a7b8494a06472d8b0ebe06a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 20 Jun 2019 01:54:57 +0300 Subject: [PATCH] Add vertex setup state to Renderer --- source/renderer.cpp | 15 +++++++++++++++ source/renderer.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/source/renderer.cpp b/source/renderer.cpp index 19811146..c213f0a9 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -14,6 +14,7 @@ #include "texturing.h" #include "texunit.h" #include "vertexarray.h" +#include "vertexsetup.h" #include "windingtest.h" using namespace std; @@ -142,6 +143,11 @@ void Renderer::set_mesh(const Mesh *m) state->mesh = m; } +void Renderer::set_vertex_setup(const VertexSetup *vs) +{ + state->vertex_setup = vs; +} + void Renderer::set_winding_test(const WindingTest *w) { state->winding_test = w; @@ -221,6 +227,7 @@ void Renderer::end() Lighting::unbind(); Clipping::unbind(); Program::unbind(); + VertexSetup::unbind(); Buffer::unbind_from(ELEMENT_ARRAY_BUFFER); WindingTest::unbind(); @@ -374,8 +381,15 @@ void Renderer::apply_state() state->mesh->bind(); } else + { Mesh::unbind(); + if(state->vertex_setup) + state->vertex_setup->bind(); + else + VertexSetup::unbind(); + } + if(state->winding_test) { if(state->reverse_winding) @@ -421,6 +435,7 @@ Renderer::State::State(): shprog(0), shdata_count(0), mesh(0), + vertex_setup(0), winding_test(0), reverse_winding(false) { } diff --git a/source/renderer.h b/source/renderer.h index 3bdf5341..b2fcf4c4 100644 --- a/source/renderer.h +++ b/source/renderer.h @@ -21,6 +21,7 @@ class Program; class Renderable; class Texture; class Texturing; +class VertexSetup; class WindingTest; /** @@ -77,6 +78,7 @@ private: const Program *shprog; unsigned shdata_count; const Mesh *mesh; + const VertexSetup *vertex_setup; const WindingTest *winding_test; bool reverse_winding; @@ -149,6 +151,7 @@ public: void add_shader_data(const ProgramData &data); void set_mesh(const Mesh *); + void set_vertex_setup(const VertexSetup *); void set_winding_test(const WindingTest *); void set_reverse_winding(bool); -- 2.45.2