]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/shadowmap.h
Access builtin resources through a global instance
[libs/gl.git] / source / effects / shadowmap.h
index e142fc8cafdd56023459035f53d48e73205c997b..a3c3a8f2f6335fb63a460887d25055a4e8e32943 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_GL_SHADOWMAP_H_
 #define MSP_GL_SHADOWMAP_H_
 
+#include "camera.h"
 #include "effect.h"
 #include "framebuffer.h"
 #include "programdata.h"
@@ -11,10 +12,10 @@ namespace Msp {
 namespace GL {
 
 class Light;
-class Scene;
+class Resources;
 
 /**
-Creates shadows on a Scene through a shadow map texture.  In the preparation
+Creates shadows on a renderable through a shadow map texture.  In the setup
 phase, the scene is rendered to a depth texture from the point of view of the
 lightsource.  This texture is then used in the rendering phase together with
 texture coordinate generation to determine whether each fragment is lit.
@@ -24,21 +25,25 @@ class ShadowMap: public Effect
 private:
        unsigned size;
        const Light &light;
+       Renderable &shadow_caster;
        Framebuffer fbo;
+       Camera shadow_camera;
        Matrix shadow_matrix;
        Texture2D depth_buf;
-       RefPtr<Sampler> sampler;
+       const Sampler &sampler;
        Vector3 target;
        float radius;
        float depth_bias;
-       mutable ProgramData shdata;
+       ProgramData shdata;
        bool rendered;
 
-       static WeakPtr<Sampler> shadow_sampler;
-
 public:
-       ShadowMap(unsigned, Renderable &, const Light &);
+       ShadowMap(unsigned, Renderable &, const Light &, Renderable &);
+       DEPRECATED ShadowMap(unsigned, Renderable &, const Light &);
+private:
+       void init(unsigned);
 
+public:
        /** Sets the ShadowMap target point and radius.  The transformation matrix is
        computed so that a sphere with the specified parameters will be completely
        covered by the ShadowMap. */
@@ -61,7 +66,7 @@ public:
        virtual void setup_frame(Renderer &);
        virtual void finish_frame();
 
-       virtual void render(Renderer &, const Tag & = Tag()) const;
+       virtual void render(Renderer &, Tag = Tag()) const;
 };
 
 } // namespace GL