]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pipeline.cpp
Move PipelinePass inside Pipeline and make the data members private
[libs/gl.git] / source / pipeline.cpp
index eca9a49a3c22dfca97cfa5119da4e2d53710ec7a..ce15597080618114fc719e1e332732f20809cb76 100644 (file)
@@ -1,7 +1,6 @@
 #include <msp/core/maputils.h>
 #include "blend.h"
 #include "camera.h"
-#include "effect.h"
 #include "framebuffer.h"
 #include "lighting.h"
 #include "pipeline.h"
@@ -35,6 +34,9 @@ Pipeline::~Pipeline()
        delete fbo;
        delete color_buf;
        delete depth_buf;
+       delete fbo_ms;
+       delete color_buf_ms;
+       delete depth_buf_ms;
 }
 
 void Pipeline::set_hdr(bool h)
@@ -56,19 +58,19 @@ void Pipeline::set_camera(const Camera *c)
        camera = c;
 }
 
-PipelinePass &Pipeline::add_pass(const Tag &tag)
+Pipeline::Pass &Pipeline::add_pass(const Tag &tag)
 {
-       PipelinePass &pass = insert_unique(passes, tag, PipelinePass())->second;
+       Pass &pass = insert_unique(passes, tag, Pass())->second;
        pass_order.push_back(tag);
        return pass;
 }
 
-PipelinePass &Pipeline::get_pass(const Tag &tag)
+Pipeline::Pass &Pipeline::get_pass(const Tag &tag)
 {
        return get_item(passes, tag);
 }
 
-const PipelinePass &Pipeline::get_pass(const Tag &tag) const
+const Pipeline::Pass &Pipeline::get_pass(const Tag &tag) const
 {
        return get_item(passes, tag);
 }
@@ -108,11 +110,6 @@ void Pipeline::remove_renderable(const Renderable &r)
                }
 }
 
-void Pipeline::add_effect(Effect &e)
-{
-       effects.push_back(&e);
-}
-
 void Pipeline::add_postprocessor(PostProcessor &pp)
 {
        postproc.push_back(&pp);
@@ -124,21 +121,15 @@ void Pipeline::add_postprocessor(PostProcessor &pp)
 
 void Pipeline::render(Renderer &renderer, const Tag &tag) const
 {
-       const PipelinePass &pass = get_pass(tag);
+       const Pass &pass = get_pass(tag);
 
-       Bind bind_depth_test(pass.depth_test);
-       Bind bind_blend(pass.blend);
-       Bind bind_lighting(pass.lighting);
-
-       for(vector<Effect *>::const_iterator i=pass.effects.begin(); i!=pass.effects.end(); ++i)
-               (*i)->prepare();
+       Bind bind_depth_test(pass.get_depth_test());
+       Bind bind_blend(pass.get_blend());
+       Bind bind_lighting(pass.get_lighting());
 
        for(vector<Slot>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
                if(i->passes.empty() || i->passes.count(tag))
                        i->renderable->render(renderer, tag);
-
-       for(vector<Effect *>::const_iterator i=pass.effects.end(); i!=pass.effects.begin();)
-               (*--i)->cleanup();
 }
 
 void Pipeline::render_all() const
@@ -153,16 +144,10 @@ void Pipeline::render_all() const
                f->clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
        }
 
-       for(vector<Effect *>::const_iterator i=effects.begin(); i!=effects.end(); ++i)
-               (*i)->prepare();
-
        Renderer renderer(camera);
        for(vector<Tag>::const_iterator i=pass_order.begin(); i!=pass_order.end(); ++i)
                render(renderer, *i);
 
-       for(vector<Effect *>::const_iterator i=effects.end(); i!=effects.begin();)
-               (*--i)->cleanup();
-
        if(fbo)
        {
                if(fbo_ms)
@@ -219,6 +204,28 @@ void Pipeline::create_fbos()
 }
 
 
+Pipeline::Pass::Pass():
+       lighting(0),
+       depth_test(0),
+       blend(0)
+{ }
+
+void Pipeline::Pass::set_lighting(const Lighting *l)
+{
+       lighting = l;
+}
+
+void Pipeline::Pass::set_depth_test(const DepthTest *d)
+{
+       depth_test = d;
+}
+
+void Pipeline::Pass::set_blend(const Blend *b)
+{
+       blend = b;
+}
+
+
 Pipeline::Slot::Slot(const Renderable *r):
        renderable(r)
 { }