virtual const Matrix *get_matrix() const { return renderable.get_matrix(); }
- virtual void setup_frame() const { renderable.setup_frame(); }
- virtual void finish_frame() const { renderable.finish_frame(); }
+ virtual void setup_frame(Renderer &r) { renderable.setup_frame(r); }
+ virtual void finish_frame() { renderable.finish_frame(); }
};
} // namespace GL
}
-void EnvironmentMap::setup_frame() const
+void EnvironmentMap::setup_frame(Renderer &renderer)
{
if(rendered)
return;
rendered = true;
- renderable.setup_frame();
- environment.setup_frame();
+ renderable.setup_frame(renderer);
+ environment.setup_frame(renderer);
Renderer env_renderer(0);
const Matrix *matrix = renderable.get_matrix();
Framebuffer::unbind();
}
-void EnvironmentMap::finish_frame() const
+void EnvironmentMap::finish_frame()
{
if(rendered)
{
Renderable &environment;
TextureCube env_tex;
Renderbuffer depth_buf;
- mutable Framebuffer fbo[6];
- mutable Camera camera;
+ Framebuffer fbo[6];
+ Camera camera;
mutable ProgramData shdata;
- mutable bool rendered;
+ bool rendered;
public:
EnvironmentMap(unsigned size, Renderable &rend, Renderable &env);
- virtual void setup_frame() const;
- virtual void finish_frame() const;
+ virtual void setup_frame(Renderer &);
+ virtual void finish_frame();
virtual void render(Renderer &, const Tag &) const;
};
}
}
-void InstanceScene::setup_frame() const
+void InstanceScene::setup_frame(Renderer &renderer)
{
for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
- (*j)->setup_frame();
+ (*j)->setup_frame(renderer);
}
-void InstanceScene::finish_frame() const
+void InstanceScene::finish_frame()
{
for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
virtual void add(Renderable &);
virtual void remove(Renderable &);
- virtual void setup_frame() const;
- virtual void finish_frame() const;
+ virtual void setup_frame(Renderer &);
+ virtual void finish_frame();
using Scene::render;
virtual void render(Renderer &, const Tag &tag = Tag()) const;
renderables.insert(i, &r);
}
-void OrderedScene::setup_frame() const
+void OrderedScene::setup_frame(Renderer &renderer)
{
for(RenderableList::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
- (*i)->setup_frame();
+ (*i)->setup_frame(renderer);
}
-void OrderedScene::finish_frame() const
+void OrderedScene::finish_frame()
{
for(RenderableList::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
(*i)->finish_frame();
void insert(unsigned, Renderable &);
void insert_after(Renderable &, Renderable &);
- virtual void setup_frame() const;
- virtual void finish_frame() const;
+ virtual void setup_frame(Renderer &);
+ virtual void finish_frame();
using Scene::render;
virtual void render(Renderer &, const Tag & = Tag()) const;
}
}
-void Pipeline::setup_frame() const
+void Pipeline::setup_frame(Renderer &renderer)
{
for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i)
- if(const Renderable *renderable = i->get_renderable())
- renderable->setup_frame();
+ if(Renderable *renderable = i->get_renderable())
+ renderable->setup_frame(renderer);
for(vector<Slot>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
- i->renderable->setup_frame();
+ i->renderable->setup_frame(renderer);
}
-void Pipeline::finish_frame() const
+void Pipeline::finish_frame()
{
for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i)
- if(const Renderable *renderable = i->get_renderable())
+ if(Renderable *renderable = i->get_renderable())
renderable->finish_frame();
for(vector<Slot>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
i->renderable->finish_frame();
}
-void Pipeline::render() const
+void Pipeline::render()
{
Renderer renderer(camera);
- setup_frame();
+ setup_frame(renderer);
render(renderer);
finish_frame();
}
/** Adds a postprocessor to the pipeline. */
void add_postprocessor(PostProcessor &);
- virtual void setup_frame() const;
- virtual void finish_frame() const;
+ virtual void setup_frame(Renderer &);
+ virtual void finish_frame();
- void render() const;
+ void render();
virtual void render(Renderer &, const Tag &tag = Tag()) const;
private:
virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return 0; }
/** Called when starting to render a new frame. */
- virtual void setup_frame() const { }
+ virtual void setup_frame(Renderer &) { }
/** Called when a complete frame has been rendered. */
- virtual void finish_frame() const { }
+ virtual void finish_frame() { }
/** Renders the Renderable. Implementors should take care to return the
renderer to the state it was in, for example by using Renderer::Push. */
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();
Bind bind_depth(DepthTest::lequal());
fbo.clear(DEPTH_BUFFER_BIT);
- Renderer renderer(&camera);
- renderable.render(renderer, "shadow");
+ Renderer shadow_renderer(&camera);
+ renderable.render(shadow_renderer, "shadow");
}
-void ShadowMap::finish_frame() const
+void ShadowMap::finish_frame()
{
renderable.finish_frame();
rendered = false;
private:
unsigned size;
const Light &light;
- mutable Framebuffer fbo;
- mutable Matrix shadow_matrix;
+ Framebuffer fbo;
+ Matrix shadow_matrix;
Texture2D depth_buf;
Vector3 target;
float radius;
float depth_bias;
mutable ProgramData shdata;
- mutable bool rendered;
+ bool rendered;
public:
ShadowMap(unsigned, Renderable &, const Light &);
thin objects from casting shadows on nearby sufraces. */
void set_depth_bias(float);
- virtual void setup_frame() const;
- virtual void finish_frame() const;
+ virtual void setup_frame(Renderer &);
+ virtual void finish_frame();
virtual void render(Renderer &, const Tag &) const;
};
}
}
-void SimpleScene::setup_frame() const
+void SimpleScene::setup_frame(Renderer &renderer)
{
populate_cache();
for(RenderableArray::const_iterator i=cache.begin(); i!=cache.end(); ++i)
- (*i)->setup_frame();
+ (*i)->setup_frame(renderer);
}
-void SimpleScene::finish_frame() const
+void SimpleScene::finish_frame()
{
for(RenderableArray::const_iterator i=cache.begin(); i!=cache.end(); ++i)
(*i)->finish_frame();
void populate_cache() const;
public:
- virtual void setup_frame() const;
- virtual void finish_frame() const;
+ virtual void setup_frame(Renderer &);
+ virtual void finish_frame();
using Scene::render;
virtual void render(Renderer &, const Tag & = Tag()) const;
if(content)
{
Renderer renderer(camera);
- content->setup_frame();
+ content->setup_frame(renderer);
content->render(renderer);
content->finish_frame();
}