]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pipeline.cpp
Add a Camera class
[libs/gl.git] / source / pipeline.cpp
index 9d5870cd1a6b03dbc71a1f4d444948684ca83a9c..0256850844fef66ebd3d32fb117d73d6be7d6dd0 100644 (file)
@@ -5,6 +5,7 @@ Copyright © 2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include "camera.h"
 #include "effect.h"
 #include "except.h"
 #include "framebuffer.h"
@@ -20,6 +21,7 @@ namespace Msp {
 namespace GL {
 
 Pipeline::Pipeline(unsigned w, unsigned h, bool d):
+       camera(0),
        width(w),
        height(h),
        hdr(d),
@@ -35,6 +37,11 @@ Pipeline::~Pipeline()
        delete depth_buf;
 }
 
+void Pipeline::set_camera(const Camera *c)
+{
+       camera = c;
+}
+
 PipelinePass &Pipeline::add_pass(const Tag &tag)
 {
        if(passes.count(tag))
@@ -107,19 +114,25 @@ void Pipeline::render(const Tag &tag) const
 
 void Pipeline::render_all() const
 {
+       if(camera)
+               camera->apply();
+
        if(fbo)
        {
                fbo->bind();
                clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
        }
+
        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();
+
        if(fbo)
                Framebuffer::unbind();
+
        // XXX Need two color buffer textures to handle multiple post-processors correctly
        for(vector<PostProcessor *>::const_iterator i=postproc.begin(); i!=postproc.end(); ++i)
                (*i)->render(*color_buf);