height(h),
fbo(f)
{
- textures.reserve(f.size());
+ bool multisample = (f.get_samples()>1);
+ textures.reserve(f.size()*(1+multisample));
unsigned samples = f.get_samples();
- for(const uint16_t *i=f.begin(); i!=f.end(); ++i)
+ for(FrameAttachment a: f)
{
- FrameAttachment fa = static_cast<FrameAttachment>(*i);
- PixelFormat pf = get_attachment_pixelformat(*i);
+ PixelFormat pf = get_attachment_pixelformat(a);
- if(samples>1)
+ Texture2D *tex2d = new Texture2D;
+ tex2d->storage(pf, width, height, 1);
+
+ if(multisample)
{
Texture2DMultisample *tex2d_ms = new Texture2DMultisample;
tex2d_ms->storage(pf, width, height, samples);
- fbo.attach(fa, *tex2d_ms);
+ fbo.attach(a, *tex2d_ms, tex2d);
textures.push_back(tex2d_ms);
+ textures.push_back(tex2d);
}
else
{
- Texture2D *tex2d = new Texture2D;
- tex2d->storage(pf, width, height, 1);
- fbo.attach(fa, *tex2d);
+ fbo.attach(a, *tex2d);
textures.push_back(tex2d);
}
}
if(i>=textures.size())
throw out_of_range("RenderTarget::get_target_texture");
if(fbo.get_format().get_samples()>1)
- throw invalid_operation("RenderTarget::get_target_texture");
+ i = i*2+1;
return *static_cast<const Texture2D *>(textures[i]);
}
{
#ifdef DEBUG
fbo.set_debug_name(name+" [FBO]");
- const FrameFormat &fmt = fbo.get_format();
+ bool multisample = (fbo.get_format().get_samples()>1);
unsigned i = 0;
- for(const uint16_t *j=fmt.begin(); j!=fmt.end(); ++i, ++j)
+ for(FrameAttachment a: fbo.get_format())
{
- unsigned attach_pt = get_attach_point(static_cast<FrameAttachment>(*j));
+ unsigned attach_pt = get_attach_point(a);
string tex_name;
if(attach_pt==get_attach_point(DEPTH_ATTACHMENT))
else
tex_name = Msp::format("%s/color%d", name, attach_pt);
- textures[i]->set_debug_name(tex_name+".tex2d");
+ textures[i++]->set_debug_name(tex_name+".tex");
+ if(multisample)
+ textures[i++]->set_debug_name(tex_name+"_resolve.tex");
}
#else
(void)name;