]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Deprecate the mipmap_levels parameter in Texture
[libs/gl.git] / source / texturecube.cpp
index da7bb9250c59377267f0453163898c27ccff5801..82447e65b8f91cb53f2170aa6e44617ccbbf8aff 100644 (file)
@@ -102,6 +102,9 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
                return sub_image(face, level, 0, 0, s, s, fmt, type, data);
 
        BindRestore _bind(this);
+
+       if(!allocated)
+               glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
        glTexImage2D(face, level, ifmt, s, s, 0, get_upload_format(fmt), type, data);
 
        // XXX Allocation should be tracked per-face, but we'll run out of bits
@@ -110,7 +113,7 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
        {
                // TODO Only do this once all faces are created
                generate_mipmap();
-               allocated |= (1<<get_n_levels())-1;
+               allocated |= (1<<levels)-1;
        }
 }
 
@@ -149,7 +152,7 @@ void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool s
        image(face, 0, fmt, UNSIGNED_BYTE, img.get_data());
 }
 
-void TextureCube::image(const Graphics::Image &img, bool srgb)
+void TextureCube::image(const Graphics::Image &img, unsigned lv, bool srgb)
 {
        unsigned w = img.get_width();
        unsigned h = img.get_height();
@@ -161,7 +164,7 @@ void TextureCube::image(const Graphics::Image &img, bool srgb)
        PixelFormat fmt = pixelformat_from_graphics(img.get_format());
        if(size==0)
        {
-               unsigned l = (is_mipmapped(min_filter) ? mipmap_levels ? mipmap_levels : 0 : 1);
+               unsigned l = (is_mipmapped(min_filter) ? lv : 1);
                storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, l);
        }
        else if(w!=size || h!=size)