]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/sequence.cpp
Add inline data items to the collection
[libs/gl.git] / source / render / sequence.cpp
index b8fb6076e1fe5937ee8107aece475b5d3a763c44..06b1403bd827e934400a550cd29f2bcef919e64b 100644 (file)
@@ -47,6 +47,9 @@ void Sequence::init(unsigned w, unsigned h)
 
 Sequence::~Sequence()
 {
+       for(vector<PostProcStep>::iterator i=postproc.begin(); i!=postproc.end(); ++i)
+               if(i->owned)
+                       delete i->postproc;
        delete target[0];
        delete target[1];
        delete target_ms;
@@ -114,25 +117,25 @@ Sequence::Step &Sequence::add_step(Tag tag, Renderable &r)
 
 void Sequence::add_postprocessor(PostProcessor &pp)
 {
-       add_postprocessor(&pp, true);
+       add_postprocessor(&pp, false);
 }
 
 void Sequence::add_postprocessor_owned(PostProcessor *pp)
 {
-       add_postprocessor(pp, false);
+       add_postprocessor(pp, true);
 }
 
-void Sequence::add_postprocessor(PostProcessor *pp, bool keep)
+void Sequence::add_postprocessor(PostProcessor *pp, bool owned)
 {
-       postproc.push_back(pp);
-       if(keep)
-               postproc.back().keep();
+       postproc.push_back(PostProcStep(pp, owned));
        try
        {
                create_targets(0);
        }
        catch(...)
        {
+               if(!owned)
+                       delete pp;
                postproc.pop_back();
                throw;
        }
@@ -206,7 +209,7 @@ void Sequence::render(Renderer &renderer, Tag tag) const
                                out_fbo->bind();
                        const Texture2D &color = target[j]->get_target_texture(RENDER_COLOR);
                        const Texture2D &depth = target[j]->get_target_texture(RENDER_DEPTH);
-                       postproc[i]->render(renderer, color, depth);
+                       postproc[i].postproc->render(renderer, color, depth);
                }
        }
 }