X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Frendertarget.cpp;h=7eba2b2beb379c1a779d9fd0cc058b2cf1cc1f65;hp=00176710c4a796047e02c462e899fde26d0c8ffd;hb=94cadd1618f93239b1cb0acbd4f958257c035c98;hpb=d01902f355b1ea9a038a7f96cab37e49c6b65419 diff --git a/source/render/rendertarget.cpp b/source/render/rendertarget.cpp index 00176710..7eba2b2b 100644 --- a/source/render/rendertarget.cpp +++ b/source/render/rendertarget.cpp @@ -15,23 +15,26 @@ RenderTarget::RenderTarget(unsigned w, unsigned h, const FrameFormat &f): 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(FrameAttachment a: f) { 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(a, *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(a, *tex2d); textures.push_back(tex2d); } @@ -49,7 +52,7 @@ const Texture2D &RenderTarget::get_target_texture(unsigned i) const 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(textures[i]); } @@ -67,6 +70,7 @@ void RenderTarget::set_debug_name(const string &name) { #ifdef DEBUG fbo.set_debug_name(name+" [FBO]"); + bool multisample = (fbo.get_format().get_samples()>1); unsigned i = 0; for(FrameAttachment a: fbo.get_format()) { @@ -81,6 +85,8 @@ void RenderTarget::set_debug_name(const string &name) tex_name = Msp::format("%s/color%d", name, attach_pt); textures[i++]->set_debug_name(tex_name+".tex"); + if(multisample) + textures[i++]->set_debug_name(tex_name+"_resolve.tex"); } #else (void)name;