]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Refactor Framebuffer::update_attachment for less indentation
[libs/gl.git] / source / texturecube.cpp
index 54a008ca50930054ee6c99507c27c032f4ff4e6c..e767423fe539f9ee92fd10dd5af8f1beaa6eebb4 100644 (file)
@@ -77,11 +77,11 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
        if(s==0)
                throw out_of_range("TextureCube::image");
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
-               sub_image(face, level, 0, 0, s, s, fmt, type, data);
-       else
-               glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
+               return sub_image(face, level, 0, 0, s, s, fmt, type, data);
+
+       BindRestore _bind(this);
+       glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
 
        // XXX Allocation should be tracked per-face, but we'll run out of bits
        allocated |= 1<<level;
@@ -98,10 +98,13 @@ void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y,
        if(size==0)
                throw invalid_operation("TextureCube::sub_image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage2D(face, level, x, y, wd, ht, fmt, type, data);
+
+       if(gen_mipmap && level==0)
+               auto_generate_mipmap();
 }
 
 void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool srgb)