From d386eadfd08b556ecb05627a7ceca14652e8b1e5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 5 Dec 2016 19:04:30 +0200 Subject: [PATCH] Change the setup/finish_frame interface to be non-const There's no deprecated versions left behind because it would be impossible to make it work with Renderables that forward the calls to a Scene. Better to just get compile errors and fix them as I encounter them. --- source/effect.h | 4 ++-- source/environmentmap.cpp | 8 ++++---- source/environmentmap.h | 10 +++++----- source/instancescene.cpp | 6 +++--- source/instancescene.h | 4 ++-- source/orderedscene.cpp | 6 +++--- source/orderedscene.h | 4 ++-- source/pipeline.cpp | 16 ++++++++-------- source/pipeline.h | 6 +++--- source/renderable.h | 4 ++-- source/shadowmap.cpp | 10 +++++----- source/shadowmap.h | 10 +++++----- source/simplescene.cpp | 6 +++--- source/simplescene.h | 4 ++-- source/view.cpp | 2 +- 15 files changed, 50 insertions(+), 50 deletions(-) diff --git a/source/effect.h b/source/effect.h index 1211c3b5..4be963f6 100644 --- a/source/effect.h +++ b/source/effect.h @@ -27,8 +27,8 @@ public: 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 diff --git a/source/environmentmap.cpp b/source/environmentmap.cpp index 1e6f639a..cbb097ea 100644 --- a/source/environmentmap.cpp +++ b/source/environmentmap.cpp @@ -30,14 +30,14 @@ EnvironmentMap::EnvironmentMap(unsigned s, Renderable &r, Renderable &e): } -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(); @@ -58,7 +58,7 @@ void EnvironmentMap::setup_frame() const Framebuffer::unbind(); } -void EnvironmentMap::finish_frame() const +void EnvironmentMap::finish_frame() { if(rendered) { diff --git a/source/environmentmap.h b/source/environmentmap.h index 9c4c4d15..00677946 100644 --- a/source/environmentmap.h +++ b/source/environmentmap.h @@ -31,16 +31,16 @@ private: 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; }; diff --git a/source/instancescene.cpp b/source/instancescene.cpp index bbaf49ed..b533bae5 100644 --- a/source/instancescene.cpp +++ b/source/instancescene.cpp @@ -22,14 +22,14 @@ void InstanceScene::remove(Renderable &r) } } -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) diff --git a/source/instancescene.h b/source/instancescene.h index d23fbb1f..3f345124 100644 --- a/source/instancescene.h +++ b/source/instancescene.h @@ -25,8 +25,8 @@ public: 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; diff --git a/source/orderedscene.cpp b/source/orderedscene.cpp index f104562f..ab1ba454 100644 --- a/source/orderedscene.cpp +++ b/source/orderedscene.cpp @@ -35,13 +35,13 @@ void OrderedScene::insert_after(Renderable &after, Renderable &r) 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(); diff --git a/source/orderedscene.h b/source/orderedscene.h index ee06dfae..53f7b008 100644 --- a/source/orderedscene.h +++ b/source/orderedscene.h @@ -25,8 +25,8 @@ public: 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; diff --git a/source/pipeline.cpp b/source/pipeline.cpp index ce9c8f68..29c42324 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -136,28 +136,28 @@ void Pipeline::add_postprocessor(PostProcessor &pp) } } -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::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::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(); } diff --git a/source/pipeline.h b/source/pipeline.h index b450d0a5..1e5b6aa4 100644 --- a/source/pipeline.h +++ b/source/pipeline.h @@ -104,10 +104,10 @@ public: /** 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: diff --git a/source/renderable.h b/source/renderable.h index 18319cb4..e90ab024 100644 --- a/source/renderable.h +++ b/source/renderable.h @@ -45,10 +45,10 @@ public: virtual const Geometry::BoundingSphere *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. */ diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index d8853d9e..f461c88a 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -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,11 @@ void ShadowMap::setup_frame() const 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; diff --git a/source/shadowmap.h b/source/shadowmap.h index 658b59a9..5f2e16ec 100644 --- a/source/shadowmap.h +++ b/source/shadowmap.h @@ -24,14 +24,14 @@ class ShadowMap: public Effect 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 &); @@ -52,8 +52,8 @@ public: 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; }; diff --git a/source/simplescene.cpp b/source/simplescene.cpp index 137873da..d1fd3c1c 100644 --- a/source/simplescene.cpp +++ b/source/simplescene.cpp @@ -26,14 +26,14 @@ void SimpleScene::populate_cache() 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(); diff --git a/source/simplescene.h b/source/simplescene.h index 8b91150c..420b0090 100644 --- a/source/simplescene.h +++ b/source/simplescene.h @@ -27,8 +27,8 @@ private: 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; diff --git a/source/view.cpp b/source/view.cpp index 759e90be..cd759e48 100644 --- a/source/view.cpp +++ b/source/view.cpp @@ -40,7 +40,7 @@ void View::render() if(content) { Renderer renderer(camera); - content->setup_frame(); + content->setup_frame(renderer); content->render(renderer); content->finish_frame(); } -- 2.45.2