From: Mikko Rasa Date: Mon, 1 Nov 2021 11:50:20 +0000 (+0200) Subject: Combine the external_image functions in Texture::Loader X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=a7948dfc4192efbbf2b5ca9258fd7e72b971f8ea Combine the external_image functions in Texture::Loader Since DataFile::Loader now supports bound arguments, it can be used to set the srgb flag. --- diff --git a/source/core/texture.cpp b/source/core/texture.cpp index 54577aac..78053386 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -87,8 +87,8 @@ Texture::Loader::Loader(Texture &t, Collection *c): CollectionObjectLoader(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 diff --git a/source/core/texture.h b/source/core/texture.h index 13ff5bc9..ff56e85c 100644 --- a/source/core/texture.h +++ b/source/core/texture.h @@ -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);