X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fpipeline.cpp;h=0256850844fef66ebd3d32fb117d73d6be7d6dd0;hp=9d5870cd1a6b03dbc71a1f4d444948684ca83a9c;hb=8f2430208cfa7bb9dc5bd655dde88acc21db54d2;hpb=a93d6abc8a4a3e70fa8f6781d9804583e18ef636 diff --git a/source/pipeline.cpp b/source/pipeline.cpp index 9d5870cd..02568508 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -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::const_iterator i=effects.begin(); i!=effects.end(); ++i) (*i)->prepare(); for(vector::const_iterator i=pass_order.begin(); i!=pass_order.end(); ++i) render(*i); for(vector::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::const_iterator i=postproc.begin(); i!=postproc.end(); ++i) (*i)->render(*color_buf);