void Pipeline::set_hdr(bool h)
{
+ if(h==hdr)
+ return;
+
hdr = h;
- create_targets(true);
+ create_targets(2);
}
void Pipeline::set_multisample(unsigned s)
{
+ if(s==samples)
+ return;
+
samples = s;
- create_targets(false);
+ create_targets(1);
}
void Pipeline::set_camera(const Camera *c)
void Pipeline::add_postprocessor(PostProcessor &pp)
{
postproc.push_back(&pp);
- create_targets(false);
+ create_targets(0);
}
void Pipeline::setup_frame() const
finish_frame();
}
-void Pipeline::create_targets(bool recreate)
+void Pipeline::create_targets(unsigned recreate)
{
- if(recreate)
+ if(recreate>=2)
{
delete target[0];
delete target[1];
- delete target_ms;
target[0] = 0;
target[1] = 0;
+ }
+ if(recreate>=1)
+ {
+ delete target_ms;
target_ms = 0;
}
PixelFormat fmt = (hdr ? RGB16F : RGB);
- if(!target[0])
- target[0] = new RenderTarget(width, height, fmt);
- if(!target[1] && postproc.size()>1)
- target[1] = new RenderTarget(width, height, fmt);
+ if(!postproc.empty() || samples)
+ {
+ if(!target[0])
+ target[0] = new RenderTarget(width, height, fmt);
+ if(!target[1] && postproc.size()>1)
+ target[1] = new RenderTarget(width, height, fmt);
+ }
if(!target_ms && samples)
target_ms = new MultisampleTarget(width, height, samples, fmt);
depth.set_wrap(CLAMP_TO_EDGE);
depth.storage(DEPTH_COMPONENT, w, h);
fbo.attach(DEPTH_ATTACHMENT, depth, 0);
+
+ fbo.require_complete();
}
depth.storage_multisample(s, DEPTH_COMPONENT, w, h);
fbo.attach(DEPTH_ATTACHMENT, depth);
+
+ fbo.require_complete();
}
} // namespace GL