]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderer.cpp
Don't store ProgramData in Lighting
[libs/gl.git] / source / renderer.cpp
index 5108ff4c8a48b26ba1283bb66027d4cc17899a56..606dd341336fcbc8668bc8724e38898f9fe084bb 100644 (file)
@@ -11,6 +11,7 @@
 #include "renderer.h"
 #include "texture.h"
 #include "texturing.h"
+#include "texunit.h"
 #include "vertexarray.h"
 #include "windingtest.h"
 
@@ -74,6 +75,11 @@ void Renderer::set_texturing(const Texturing *t)
        state->texture = 0;
 }
 
+unsigned Renderer::allocate_effect_texunit()
+{
+       return --state->lowest_effect_texunit;
+}
+
 void Renderer::set_material(const Material *m)
 {
        state->material = m;
@@ -84,9 +90,7 @@ void Renderer::set_lighting(const Lighting *l)
        state->lighting = l;
        state->lighting_matrix = mtx_stack.top();
        if(l)
-               /* XXX I'm not happy with this, but can't come up with anything better
-               right now. */
-               const_cast<Lighting *>(l)->update_shader_data(mtx_stack.top());
+               l->update_shader_data(standard_shdata, mtx_stack.top());
        lighting_changed = true;
 }
 
@@ -240,8 +244,6 @@ void Renderer::apply_state()
                                        nm(i, j) = m(i, j);
                        nm = transpose(invert(nm));
                        standard_shdata.uniform_matrix3("eye_obj_normal_matrix", &nm(0, 0));
-                       if(state->lighting)
-                               state->lighting->get_shader_data().apply();
                        if(state->material)
                                state->material->get_shader_data().apply();
                        standard_shdata.apply();
@@ -291,12 +293,14 @@ void Renderer::apply_state()
 Renderer::State::State():
        texture(0),
        texturing(0),
+       lowest_effect_texunit(TexUnit::get_n_units()),
        material(0),
        lighting(0),
        shprog(0),
        shdata_count(0),
        mesh(0),
-       winding_test(0)
+       winding_test(0),
+       reverse_winding(false)
 { }