From: Mikko Rasa Date: Thu, 16 Sep 2021 22:00:07 +0000 (+0300) Subject: Remove automatic mipmap generation from the public interface of Texture X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4e9fe48180c7b4646ac2591e172de61f7a693b32;p=libs%2Fgl.git Remove automatic mipmap generation from the public interface of Texture The flag is now only used in conjunction of textures loaded from datafiles. Mipmap generation can still be manually triggered. This causes some lossage with the allocation flags if the texture storage extension is not supported. I'll likely refactor the allocation system soon. --- diff --git a/source/core/texture.cpp b/source/core/texture.cpp index b4004670..5c82dbe5 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -133,11 +133,6 @@ void Texture::set_parameter_i(GLenum param, int value) const glTexParameteri(target, param, value); } -bool Texture::can_generate_mipmap() -{ - return EXT_framebuffer_object; -} - void Texture::generate_mipmap() { // glGenerateMipmap is defined here @@ -152,14 +147,6 @@ void Texture::generate_mipmap() } } -void Texture::set_auto_generate_mipmap(bool gm) -{ - if(gm) - static Require _req(EXT_framebuffer_object); - - auto_gen_mipmap = gm; -} - void Texture::load_image(const string &fn, bool) { load_image(fn, 0U); @@ -235,6 +222,12 @@ void Texture::Loader::init() add("mipmap_levels", &Loader::mipmap_levels); } +void Texture::Loader::finish() +{ + if(obj.auto_gen_mipmap) + obj.generate_mipmap(); +} + void Texture::Loader::load_external_image(Graphics::Image &img, const string &fn) { RefPtr io = get_collection().open_raw(fn); @@ -269,7 +262,7 @@ void Texture::Loader::external_image_common(const string &fn) void Texture::Loader::generate_mipmap(bool gm) { - obj.set_auto_generate_mipmap(gm); + obj.auto_gen_mipmap = gm; } void Texture::Loader::image_data(const string &data) diff --git a/source/core/texture.h b/source/core/texture.h index 1631f69f..04a81085 100644 --- a/source/core/texture.h +++ b/source/core/texture.h @@ -37,6 +37,8 @@ protected: private: void init(); + virtual void finish(); + protected: void load_external_image(Graphics::Image &, const std::string &); @@ -84,17 +86,8 @@ protected: public: PixelFormat get_format() const { return format; } - static bool can_generate_mipmap(); - void generate_mipmap(); - /** Sets automatic mipmap generation. If enabled, mipmaps are generated - when a texture image is uploaded. */ - void set_auto_generate_mipmap(bool); - - /// Deprecated. Use set_auto_generate_mipmap instead. - DEPRECATED void set_generate_mipmap(bool g) { set_auto_generate_mipmap(g); } - /// Loads a Graphics::Image from a file and uploads it to the texture. virtual void load_image(const std::string &, unsigned = 0); diff --git a/source/core/texture1d.cpp b/source/core/texture1d.cpp index 1dbe36eb..03e02159 100644 --- a/source/core/texture1d.cpp +++ b/source/core/texture1d.cpp @@ -86,11 +86,6 @@ void Texture1D::image(unsigned level, const void *data) glTexImage1D(target, level, fmt, get_level_size(level), 0, comp, type, data); allocated |= 1<