]> git.tdb.fi Git - libs/gl.git/blobdiff - source/shadowmap.cpp
Refresh lighting and culling uniforms if the camera changes in pop_state
[libs/gl.git] / source / shadowmap.cpp
index 4ad192cad1d737cb90dc464f4e9ca7b639ca8d70..6056141f763376edaa39531b0070d348c9effb9f 100644 (file)
@@ -15,7 +15,7 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-ShadowMap::ShadowMap(unsigned s, const Renderable &r, const Light &l):
+ShadowMap::ShadowMap(unsigned s, Renderable &r, const Light &l):
        Effect(r),
        size(s),
        light(l),
@@ -56,13 +56,13 @@ void ShadowMap::set_depth_bias(float b)
        depth_bias = b;
 }
 
-void ShadowMap::setup_frame() const
+void ShadowMap::setup_frame(Renderer &renderer)
 {
        if(rendered)
                return;
 
        rendered = true;
-       renderable.setup_frame();
+       renderable.setup_frame(renderer);
 
        Camera camera;
        const Vector4 &lpos = light.get_position();
@@ -84,11 +84,13 @@ void ShadowMap::setup_frame() const
        Bind bind_depth(DepthTest::lequal());
        fbo.clear(DEPTH_BUFFER_BIT);
 
-       Renderer renderer(&camera);
-       renderable.render(renderer, "shadow");
+       Renderer::Push push(renderer);
+       renderer.set_camera(camera);
+
+       renderer.render(renderable, "shadow");
 }
 
-void ShadowMap::finish_frame() const
+void ShadowMap::finish_frame()
 {
        renderable.finish_frame();
        rendered = false;