]> git.tdb.fi Git - libs/gl.git/commitdiff
Add vertex setup state to Renderer
authorMikko Rasa <tdb@tdb.fi>
Wed, 19 Jun 2019 22:54:57 +0000 (01:54 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 19 Jun 2019 22:54:57 +0000 (01:54 +0300)
source/renderer.cpp
source/renderer.h

index 19811146235ec6622c0917a1536190490597bff8..c213f0a987218f579fbc4991fc6722bece0e083a 100644 (file)
@@ -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)
 { }
index 3bdf5341e96b9bd6b1122329ffc522b71834233d..b2fcf4c4e6fba065980c7739ecf375a5a4bbda87 100644 (file)
@@ -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);