]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/framebuffer.cpp
Adapt to changes in mspmath
[libs/gl.git] / source / core / framebuffer.cpp
index b0777171448b5a27222e4b631e8d04cc52143ae6..45eaff656b65322a5d137133061e9e2ce35924ac 100644 (file)
@@ -60,6 +60,7 @@ void Framebuffer::check_size()
                {
                        unsigned w = 0;
                        unsigned h = 0;
+                       unsigned l = 1;
                        if(const Texture2D *tex2d = dynamic_cast<const Texture2D *>(a.tex))
                        {
                                w = max(tex2d->get_width()>>a.level, 1U);
@@ -74,23 +75,27 @@ void Framebuffer::check_size()
                        {
                                w = max(tex3d->get_width()>>a.level, 1U);
                                h = max(tex3d->get_height()>>a.level, 1U);
+                               l = (a.layer<0 ? tex3d->get_depth() : 1);
                        }
                        else if(const TextureCube *tex_cube = dynamic_cast<const TextureCube *>(a.tex))
                        {
                                w = max(tex_cube->get_size()>>a.level, 1U);
                                h = w;
+                               l = (a.layer<0 ? 6 : 1);
                        }
 
                        if(first)
                        {
                                width = w;
                                height = h;
+                               layers = l;
                                first = false;
                        }
                        else
                        {
                                width = min(width, w);
                                height = min(height, h);
+                               layers = min(layers, l);
                        }
                }
 }
@@ -165,6 +170,20 @@ void Framebuffer::detach(FrameAttachment attch)
        }
 }
 
+const Texture *Framebuffer::get_attachment(FrameAttachment attch) const
+{
+       if(attachments.empty())
+               return 0;
+
+       int i = format.index(attch);
+       return (i>=0 ? attachments[i].tex : 0);
+}
+
+const Texture *Framebuffer::get_attachment(unsigned i) const
+{
+       return (i<attachments.size() ? attachments[i].tex : 0);
+}
+
 void Framebuffer::require_complete() const
 {
        bool layered = (!attachments.empty() && attachments.front().layer<0);