]> git.tdb.fi Git - libs/gl.git/commitdiff
Compute Framebuffer size correctly when texture mipmaps are attached
authorMikko Rasa <tdb@tdb.fi>
Tue, 6 Dec 2016 21:53:48 +0000 (23:53 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 7 Dec 2016 00:28:35 +0000 (02:28 +0200)
source/framebuffer.cpp

index 638a710f464431cd7a708434e1fa980157d9b009..a3197f5947cced462fa8c12d7c5ac9b4f68ed2f8 100644 (file)
@@ -168,12 +168,12 @@ void Framebuffer::check_size()
                        else if(i->type==GL_TEXTURE_2D)
                        {
                                Texture2D *tex = static_cast<Texture2D *>(i->tex);
-                               width = tex->get_width();
-                               height = tex->get_height();
+                               width = max(tex->get_width()>>i->level, 1U);
+                               height = max(tex->get_height()>>i->level, 1U);
                        }
                        else if(i->type==GL_TEXTURE_CUBE_MAP)
                        {
-                               width = static_cast<TextureCube *>(i->tex)->get_size();
+                               width = max(static_cast<TextureCube *>(i->tex)->get_size()>>i->level, 1U);
                                height = width;
                        }
                        if(full_viewport)