]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture2d.cpp
Move texture sampler state to a separate object
[libs/gl.git] / source / texture2d.cpp
index 7586862591675534a50bf13b076021701ec004b0..78011d3046ea5fb8189f823096fa8d730c651033 100644 (file)
@@ -143,10 +143,7 @@ void Texture2D::image(const Graphics::Image &img, unsigned lv, bool srgb, bool f
        unsigned h = img.get_height();
        PixelFormat fmt = pixelformat_from_graphics(img.get_format());
        if(width==0)
-       {
-               unsigned l = (is_mipmapped(min_filter) ? lv : 1);
-               storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, l);
-       }
+               storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, lv);
        else if(w!=width || h!=height || (lv && lv!=levels))
                throw incompatible_data("Texture2D::image");
 
@@ -194,6 +191,7 @@ void Texture2D::unload()
        allocated = 0;
        // TODO check which params actually need refreshing
        dirty_params = -1;
+       default_sampler.unload();
 }
 
 
@@ -213,6 +211,7 @@ void Texture2D::Loader::init()
 {
        add("raw_data", &Loader::raw_data);
        add("storage", &Loader::storage);
+       add("storage", &Loader::storage_levels);
 }
 
 void Texture2D::Loader::raw_data(const string &data)
@@ -225,6 +224,11 @@ void Texture2D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h)
        obj.storage(fmt, w, h);
 }
 
+void Texture2D::Loader::storage_levels(PixelFormat fmt, unsigned w, unsigned h, unsigned l)
+{
+       obj.storage(fmt, w, h, l);
+}
+
 
 Texture2D::AsyncLoader::AsyncLoader(Texture2D &t, IO::Seekable &i):
        texture(t),