X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fframebuffer.cpp;h=6e7d9dc9971878a7647f26ecf49be6f10fd54712;hp=05cd27f0395947fab9465c313b25db1a7ff09bd1;hb=2e1a887ef0d4a0af8b8aa781619cff6d75692e14;hpb=a0538cdd026622f7f0f3e2ac1f9c2bd54c4a6014 diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 05cd27f0..6e7d9dc9 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -200,36 +200,49 @@ void Framebuffer::update() const void Framebuffer::check_size() { + bool first = true; for(vector::iterator i=attachments.begin(); i!=attachments.end(); ++i) if(i->tex) { GLenum type = i->tex->get_target(); + unsigned w = 0; + unsigned h = 0; if(type==GL_TEXTURE_2D) { Texture2D *tex = static_cast(i->tex); - width = max(tex->get_width()>>i->level, 1U); - height = max(tex->get_height()>>i->level, 1U); + w = max(tex->get_width()>>i->level, 1U); + h = max(tex->get_height()>>i->level, 1U); } else if(type==GL_TEXTURE_2D_MULTISAMPLE) { Texture2DMultisample *tex = static_cast(i->tex); - width = tex->get_width(); - height = tex->get_height(); + w = tex->get_width(); + h = tex->get_height(); } else if(type==GL_TEXTURE_3D || type==GL_TEXTURE_2D_ARRAY) { Texture3D *tex = static_cast(i->tex); - width = max(tex->get_width()>>i->level, 1U); - height = max(tex->get_height()>>i->level, 1U); + w = max(tex->get_width()>>i->level, 1U); + h = max(tex->get_height()>>i->level, 1U); } else if(type==GL_TEXTURE_CUBE_MAP) { - width = max(static_cast(i->tex)->get_size()>>i->level, 1U); - height = width; + w = max(static_cast(i->tex)->get_size()>>i->level, 1U); + h = w; } - break; - } + if(first) + { + width = w; + height = h; + first = false; + } + else + { + width = min(width, w); + height = min(height, h); + } + } } void Framebuffer::set_attachment(FrameAttachment attch, Texture &tex, unsigned level, int layer, unsigned samples)