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;
}
}
+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)
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);
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)
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());
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())
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)
{