]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderer.cpp
Drop Id tags and copyright notices from files
[libs/gl.git] / source / renderer.cpp
index bfd446e9f42ccc30aa47306d26f6d535fe1b4ea9..72043cd153f1d669b7f69011f97981d1a4793aea 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2011  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <msp/core/except.h>
 #include "batch.h"
 #include "buffer.h"
@@ -16,6 +9,7 @@ Distributed under the LGPL
 #include "texture.h"
 #include "texturing.h"
 #include "vertexarray.h"
+#include "windingtest.h"
 
 using namespace std;
 
@@ -54,6 +48,7 @@ Renderer::~Renderer()
        Material::unbind();
        Program::unbind();
        Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
+       WindingTest::unbind();
 }
 
 void Renderer::set_texture(const Texture *t)
@@ -101,6 +96,11 @@ void Renderer::set_element_buffer(const Buffer *b)
        element_buffer = b;
 }
 
+void Renderer::set_winding_test(const WindingTest *w)
+{
+       state->winding_test = w;
+}
+
 void Renderer::push_state()
 {
        state_stack.push_back(state_stack.back());
@@ -134,7 +134,10 @@ void Renderer::draw(const Batch &batch)
 
        // Until VertexArray acquires VAO support and becomes Bindable
        if(vertex_array_changed)
+       {
                vertex_array->apply();
+               vertex_array_changed = false;
+       }
 
        if(element_buffer)
                element_buffer->bind_to(ELEMENT_ARRAY_BUFFER);
@@ -173,6 +176,11 @@ void Renderer::apply_state()
        else
                Program::unbind();
 
+       if(state->winding_test)
+               state->winding_test->bind();
+       else
+               WindingTest::unbind();
+
        if(mtx_changed)
        {
                MatrixStack::modelview() = mtx_stack.top();
@@ -185,7 +193,8 @@ Renderer::State::State():
        texture(0),
        texturing(0),
        material(0),
-       shprog(0)
+       shprog(0),
+       winding_test(0)
 { }