]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture2d.cpp
Make explicit mipmap generation public
[libs/gl.git] / source / texture2d.cpp
index 44ee6406420e85f261c988f5e8b14f678c90cfe3..94224147c70434b53bcb8ef9ea78328e9f81284b 100644 (file)
@@ -104,9 +104,9 @@ void Texture2D::image(unsigned level, PixelFormat fmt, DataType type, const void
        glTexImage2D(target, level, ifmt, w, h, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
-       if(gen_mipmap && level==0)
+       if(auto_gen_mipmap==1 && level==0)
        {
-               auto_generate_mipmap();
+               generate_mipmap();
                allocated |= (1<<get_n_levels())-1;
        }
 }
@@ -125,8 +125,8 @@ void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht
        else
                glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
 
-       if(gen_mipmap && level==0)
-               auto_generate_mipmap();
+       if(auto_gen_mipmap==1 && level==0)
+               generate_mipmap();
 }
 
 void Texture2D::image(const Graphics::Image &img, bool srgb)
@@ -141,7 +141,7 @@ void Texture2D::image(const Graphics::Image &img, bool srgb, bool from_buffer)
        PixelFormat fmt = pixelformat_from_graphics(img.get_format());
        if(width==0)
        {
-               unsigned l = (is_mipmapped(min_filter) ? 0 : 1);
+               unsigned l = (is_mipmapped(min_filter) ? mipmap_levels ? mipmap_levels : 0 : 1);
                storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, l);
        }
        else if(w!=width || h!=height)
@@ -218,8 +218,6 @@ void Texture2D::Loader::raw_data(const string &data)
 
 void Texture2D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h)
 {
-       if(srgb)
-               fmt = get_srgb_pixelformat(fmt);
        obj.storage(fmt, w, h);
 }