]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pipeline.cpp
Check for OES_mapbuffer in Buffer::unmap
[libs/gl.git] / source / pipeline.cpp
index 29c42324add861d9e7813ba252f4fde9217f20b5..27cc3e3c63cc9d274e3573c7da915b21b846899d 100644 (file)
@@ -9,20 +9,32 @@
 #include "renderer.h"
 #include "tests.h"
 #include "texture2d.h"
+#include "view.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),
-       target_ms(0)
+Pipeline::Pipeline(unsigned w, unsigned h, bool d)
 {
+       init(w, h);
+       hdr = d;
+}
+
+Pipeline::Pipeline(const View &view)
+{
+       init(view.get_width(), view.get_height());
+}
+
+void Pipeline::init(unsigned w, unsigned h)
+{
+       camera = 0;
+       width = w;
+       height = h;
+       hdr = false;
+       samples = 0;
+       target_ms = 0;
        target[0] = 0;
        target[1] = 0;
 }
@@ -124,7 +136,19 @@ Pipeline::Pass &Pipeline::add_pass(const Tag &tag, Renderable &r)
 
 void Pipeline::add_postprocessor(PostProcessor &pp)
 {
-       postproc.push_back(&pp);
+       add_postprocessor(&pp, true);
+}
+
+void Pipeline::add_postprocessor_owned(PostProcessor *pp)
+{
+       add_postprocessor(pp, false);
+}
+
+void Pipeline::add_postprocessor(PostProcessor *pp, bool keep)
+{
+       postproc.push_back(pp);
+       if(keep)
+               postproc.back().keep();
        try
        {
                create_targets(0);
@@ -168,7 +192,7 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
                return;
 
        const Framebuffer *out_fbo = Framebuffer::current();
-       // These is a no-ops but will ensure the related state gets restored
+       // These are no-ops but will ensure the related state gets restored
        BindRestore restore_fbo(out_fbo);
        BindRestore restore_depth_test(DepthTest::current());
        BindRestore restore_blend(Blend::current());
@@ -180,7 +204,6 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
                fbo.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
        }
 
-
        for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i)
        {
                if(const DepthTest *dt = i->get_depth_test())