]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pipeline.cpp
Add object-oriented interfaces for the various tests and blending
[libs/gl.git] / source / pipeline.cpp
index 0256850844fef66ebd3d32fb117d73d6be7d6dd0..97c452658153acb8c7561652ee22dcc0fc928961 100644 (file)
@@ -1,10 +1,11 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2009  Mikko Rasa, Mikkosoft Productions
+Copyright © 2009-2010  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include "blend.h"
 #include "camera.h"
 #include "effect.h"
 #include "except.h"
@@ -13,6 +14,7 @@ Distributed under the LGPL
 #include "pipeline.h"
 #include "postprocessor.h"
 #include "renderbuffer.h"
+#include "tests.h"
 #include "texture2d.h"
 
 using namespace std;
@@ -100,16 +102,19 @@ void Pipeline::add_postprocessor(PostProcessor &pp)
 void Pipeline::render(const Tag &tag) const
 {
        const PipelinePass &pass=get_pass(tag);
-       if(pass.lighting)
-               pass.lighting->bind();
+
+       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();
+
        for(vector<const Renderable *>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
                (*i)->render(tag);
-       for(vector<Effect *>::const_iterator i=pass.effects.end(); i--!=pass.effects.begin();)
-               (*i)->cleanup();
-       if(pass.lighting)
-               Lighting::unbind();
+
+       for(vector<Effect *>::const_iterator i=pass.effects.end(); i!=pass.effects.begin();)
+               (*--i)->cleanup();
 }
 
 void Pipeline::render_all() const
@@ -125,10 +130,12 @@ void Pipeline::render_all() const
 
        for(vector<Effect *>::const_iterator i=effects.begin(); i!=effects.end(); ++i)
                (*i)->prepare();
+
        for(vector<Tag>::const_iterator i=pass_order.begin(); i!=pass_order.end(); ++i)
                render(*i);
-       for(vector<Effect *>::const_iterator i=effects.end(); i--!=effects.begin();)
-               (*i)->cleanup();
+
+       for(vector<Effect *>::const_iterator i=effects.end(); i!=effects.begin();)
+               (*--i)->cleanup();
 
        if(fbo)
                Framebuffer::unbind();