]> git.tdb.fi Git - libs/gl.git/commitdiff
Combine the external_image functions in Texture::Loader
authorMikko Rasa <tdb@tdb.fi>
Mon, 1 Nov 2021 11:50:20 +0000 (13:50 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 1 Nov 2021 11:50:20 +0000 (13:50 +0200)
Since DataFile::Loader now supports bound arguments, it can be used to
set the srgb flag.

source/core/texture.cpp
source/core/texture.h

index 54577aacd55e06f389361f0eda96305b42a63057..78053386a1e15e80ca2414d1d6261e19e4ac73ca 100644 (file)
@@ -87,8 +87,8 @@ Texture::Loader::Loader(Texture &t, Collection *c):
        CollectionObjectLoader<Texture>(t, c),
        levels(0)
 {
-       add("external_image", &Loader::external_image);
-       add("external_image_srgb", &Loader::external_image_srgb);
+       add("external_image", &Loader::external_image, false);
+       add("external_image_srgb", &Loader::external_image, true);
        add("generate_mipmap", &Loader::generate_mipmap);
        add("image_data", &Loader::image_data);
        add("mipmap_levels", &Loader::mipmap_levels);
@@ -108,20 +108,9 @@ void Texture::Loader::load_external_image(Graphics::Image &img, const string &fn
        img.load_io(*io);
 }
 
-void Texture::Loader::external_image(const string &fn)
-{
-       obj.use_srgb_format = false;
-       external_image_common(fn);
-}
-
-void Texture::Loader::external_image_srgb(const string &fn)
-{
-       obj.use_srgb_format = true;
-       external_image_common(fn);
-}
-
-void Texture::Loader::external_image_common(const string &fn)
+void Texture::Loader::external_image(bool srgb, const string &fn)
 {
+       obj.use_srgb_format = srgb;
        if(obj.manager)
                obj.manager->set_resource_location(obj, get_collection(), fn);
        else
index 13ff5bc9f73095094a0800cd1efbd5aaa3a4246a..ff56e85cb233d97ff5b822c5360255b7c9e2a8bc 100644 (file)
@@ -49,9 +49,7 @@ protected:
                void load_external_image(Graphics::Image &, const std::string &);
 
        private:
-               void external_image(const std::string &);
-               void external_image_srgb(const std::string &);
-               void external_image_common(const std::string &);
+               void external_image(bool, const std::string &);
                void generate_mipmap(bool);
                void image_data(const std::string &);
                void mipmap_levels(unsigned);