]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture2d.cpp
Graphics::Image::get_data was renamed to get_pixels
[libs/gl.git] / source / texture2d.cpp
index fa92f1c97e52b3c980485827280def8e1c0057c2..311a3e4569704c92b99703c4a0473f508778c9e1 100644 (file)
@@ -18,7 +18,6 @@ class Texture2D::AsyncLoader: public Resource::AsyncLoader
 private:
        Texture2D &texture;
        IO::Seekable &io;
-       bool srgb_conversion;
        Buffer pixel_buffer;
        char *mapped_address;
        Graphics::Image image;
@@ -28,7 +27,6 @@ private:
 public:
        AsyncLoader(Texture2D &, IO::Seekable &);
 
-       void set_srgb_conversion(bool);
        virtual bool needs_sync() const;
        virtual bool process();
 };
@@ -149,25 +147,25 @@ void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht
        sub_image(level, x, y, wd, ht, data);
 }
 
-void Texture2D::image(const Graphics::Image &img, unsigned lv, bool srgb)
+void Texture2D::image(const Graphics::Image &img, unsigned lv)
 {
-       image(img, lv, srgb, false);
+       image(img, lv, false);
 }
 
-void Texture2D::image(const Graphics::Image &img, unsigned lv, bool srgb, bool from_buffer)
+void Texture2D::image(const Graphics::Image &img, unsigned lv, bool from_buffer)
 {
        unsigned w = img.get_width();
        unsigned h = img.get_height();
        PixelFormat fmt = pixelformat_from_image(img);
        if(width==0)
-               storage(make_pixelformat(get_components(fmt), get_component_type(fmt), srgb), w, h, lv);
+               storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, lv);
        else if(w!=width || h!=height || (lv && lv!=levels))
                throw incompatible_data("Texture2D::image");
 
        PixelStore pstore = PixelStore::from_image(img);
        BindRestore _bind_ps(pstore);
 
-       image(0, from_buffer ? 0 : img.get_data());
+       image(0, from_buffer ? 0 : img.get_pixels());
 }
 
 unsigned Texture2D::get_n_levels() const
@@ -188,11 +186,9 @@ void Texture2D::get_level_size(unsigned level, unsigned &w, unsigned &h) const
                h = 1;
 }
 
-Resource::AsyncLoader *Texture2D::load(IO::Seekable &io, const Resources *res)
+Resource::AsyncLoader *Texture2D::load(IO::Seekable &io, const Resources *)
 {
        AsyncLoader *ldr = new AsyncLoader(*this, io);
-       if(res)
-               ldr->set_srgb_conversion(res->get_srgb_conversion());
        return ldr;
 }
 
@@ -248,17 +244,11 @@ void Texture2D::Loader::storage_levels(PixelFormat fmt, unsigned w, unsigned h,
 Texture2D::AsyncLoader::AsyncLoader(Texture2D &t, IO::Seekable &i):
        texture(t),
        io(i),
-       srgb_conversion(false),
        pixel_buffer(PIXEL_UNPACK_BUFFER),
        mapped_address(0),
        phase(0)
 { }
 
-void Texture2D::AsyncLoader::set_srgb_conversion(bool c)
-{
-       srgb_conversion = c;
-}
-
 bool Texture2D::AsyncLoader::needs_sync() const
 {
        return phase%2;
@@ -280,7 +270,7 @@ bool Texture2D::AsyncLoader::process()
        }
        else if(phase==2)
        {
-               const char *data = reinterpret_cast<const char *>(image.get_data());
+               const char *data = reinterpret_cast<const char *>(image.get_pixels());
                copy(data, data+n_bytes, mapped_address);
        }
        else if(phase==3)
@@ -299,7 +289,7 @@ bool Texture2D::AsyncLoader::process()
                        else
                                glGenTextures(1, &texture.id);
                }
-               texture.image(image, 0, srgb_conversion, true);
+               texture.image(image, 0, true);
        }
 
        ++phase;