]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pipeline.cpp
Remove last fragments of rendererless rendering
[libs/gl.git] / source / pipeline.cpp
index 27cc3e3c63cc9d274e3573c7da915b21b846899d..9fcf35188fc42589e280ed33a7e9b6f68aff2266 100644 (file)
@@ -27,12 +27,18 @@ Pipeline::Pipeline(const View &view)
        init(view.get_width(), view.get_height());
 }
 
+Pipeline::Pipeline(const Framebuffer &fbo)
+{
+       init(fbo.get_width(), fbo.get_height());
+}
+
 void Pipeline::init(unsigned w, unsigned h)
 {
        camera = 0;
        width = w;
        height = h;
        hdr = false;
+       alpha = false;
        samples = 0;
        target_ms = 0;
        target[0] = 0;
@@ -64,6 +70,24 @@ void Pipeline::set_hdr(bool h)
        }
 }
 
+void Pipeline::set_alpha(bool a)
+{
+       if(a==alpha)
+               return;
+
+       bool old_alpha = alpha;
+       alpha = a;
+       try
+       {
+               create_targets(2);
+       }
+       catch(...)
+       {
+               alpha = old_alpha;
+               throw;
+       }
+}
+
 void Pipeline::set_multisample(unsigned s)
 {
        if(s==samples)
@@ -178,14 +202,6 @@ void Pipeline::finish_frame()
                i->renderable->finish_frame();
 }
 
-void Pipeline::render()
-{
-       Renderer renderer(camera);
-       setup_frame(renderer);
-       render(renderer);
-       finish_frame();
-}
-
 void Pipeline::render(Renderer &renderer, const Tag &tag) const
 {
        if(tag.id)
@@ -264,7 +280,7 @@ void Pipeline::create_targets(unsigned recreate)
                target_ms = 0;
        }
 
-       PixelFormat color_pf = (hdr ? RGB16F : RGB);
+       PixelFormat color_pf = (hdr ? (alpha ? RGBA16F : RGB16F) : (alpha ? RGBA : RGB));
        RenderTargetFormat fmt = (RENDER_COLOR,color_pf, RENDER_DEPTH);
        if(!postproc.empty() || samples)
        {