]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pipeline.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / pipeline.cpp
diff --git a/source/pipeline.cpp b/source/pipeline.cpp
deleted file mode 100644 (file)
index 67ddf65..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-#include <msp/core/maputils.h>
-#include "blend.h"
-#include "camera.h"
-#include "framebuffer.h"
-#include "lighting.h"
-#include "pipeline.h"
-#include "postprocessor.h"
-#include "renderbuffer.h"
-#include "renderer.h"
-#include "tests.h"
-#include "texture2d.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-Pipeline::Pipeline(unsigned w, unsigned h, bool d):
-       camera(0),
-       width(w),
-       height(h),
-       hdr(d),
-       samples(0),
-       fbo(0),
-       color_buf(0),
-       depth_buf(0),
-       fbo_ms(0),
-       color_buf_ms(0),
-       depth_buf_ms(0)
-{ }
-
-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)
-{
-       hdr = h;
-       if(!postproc.empty())
-               create_fbos();
-}
-
-void Pipeline::set_multisample(unsigned s)
-{
-       samples = s;
-       if(!postproc.empty())
-               create_fbos();
-}
-
-void Pipeline::set_camera(const Camera *c)
-{
-       camera = c;
-}
-
-Pipeline::Pass &Pipeline::add_pass(const Tag &tag)
-{
-       passes.push_back(Pass(tag));
-       return passes.back();
-}
-
-void Pipeline::add_renderable(const Renderable &r)
-{
-       for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
-               if(i->renderable==&r)
-               {
-                       i->passes.clear();
-                       return;
-               }
-
-       renderables.push_back(&r);
-}
-
-void Pipeline::add_renderable_for_pass(const Renderable &r, const Tag &tag)
-{
-       for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
-               if(i->renderable==&r)
-               {
-                       i->passes.insert(tag);
-                       return;
-               }
-
-       renderables.push_back(&r);
-       renderables.back().passes.insert(tag);
-}
-
-void Pipeline::remove_renderable(const Renderable &r)
-{
-       for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
-               if(i->renderable==&r)
-               {
-                       renderables.erase(i);
-                       return;
-               }
-}
-
-void Pipeline::add_postprocessor(PostProcessor &pp)
-{
-       postproc.push_back(&pp);
-       if(!fbo)
-               create_fbos();
-       {
-       }
-}
-
-void Pipeline::render(const Tag &tag) const
-{
-       if(tag.id)
-               return;
-
-       Renderer renderer(camera);
-       render(renderer, tag);
-}
-
-void Pipeline::render(Renderer &renderer, const Tag &tag) const
-{
-       if(tag.id)
-               return;
-
-       if(fbo)
-       {
-               Framebuffer *f = (fbo_ms ? fbo_ms : fbo);
-               // XXX exception safety
-               f->bind();
-               f->clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
-       }
-
-       for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i)
-       {
-               Bind bind_depth_test(i->get_depth_test());
-               Bind bind_blend(i->get_blend());
-               Bind bind_lighting(i->get_lighting());
-
-               for(vector<Slot>::const_iterator j=renderables.begin(); j!=renderables.end(); ++j)
-                       if(j->passes.empty() || j->passes.count(i->get_tag()))
-                               j->renderable->render(renderer, i->get_tag());
-       }
-
-       if(fbo)
-       {
-               if(fbo_ms)
-                       fbo->blit_from(*fbo_ms, COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT, false);
-               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, *depth_buf);
-}
-
-void Pipeline::create_fbos()
-{
-       delete fbo;
-       delete color_buf;
-       delete depth_buf;
-
-       delete fbo_ms;
-       fbo_ms = 0;
-       delete color_buf_ms;
-       color_buf_ms = 0;
-       delete depth_buf_ms;
-       depth_buf_ms = 0;
-
-       fbo = new Framebuffer;
-
-       color_buf = new Texture2D;
-       color_buf->set_min_filter(NEAREST);
-       color_buf->set_mag_filter(NEAREST);
-       color_buf->set_wrap(CLAMP_TO_EDGE);
-       color_buf->storage((hdr ? RGB16F : RGB), width, height);
-       fbo->attach(COLOR_ATTACHMENT0, *color_buf, 0);
-
-       depth_buf = new Texture2D;
-       depth_buf->set_min_filter(NEAREST);
-       depth_buf->set_mag_filter(NEAREST);
-       depth_buf->set_wrap(CLAMP_TO_EDGE);
-       depth_buf->storage(DEPTH_COMPONENT, width, height);
-       fbo->attach(DEPTH_ATTACHMENT, *depth_buf, 0);
-
-       if(samples)
-       {
-               fbo_ms = new Framebuffer;
-
-               color_buf_ms = new Renderbuffer;
-               color_buf_ms->storage_multisample(samples, (hdr ? RGB16F : RGB), width, height);
-               fbo_ms->attach(COLOR_ATTACHMENT0, *color_buf_ms);
-
-               depth_buf_ms = new Renderbuffer;
-               depth_buf_ms->storage_multisample(samples, DEPTH_COMPONENT, width, height);
-               fbo_ms->attach(DEPTH_ATTACHMENT, *depth_buf_ms);
-       }
-}
-
-
-Pipeline::Pass::Pass(const Tag &t):
-       tag(t),
-       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)
-{ }
-
-} // namespace GL
-} // namespace Msp