From 4e9fe48180c7b4646ac2591e172de61f7a693b32 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 17 Sep 2021 01:00:07 +0300 Subject: [PATCH] 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. --- source/core/texture.cpp | 21 +++++++-------------- source/core/texture.h | 11 ++--------- source/core/texture1d.cpp | 8 -------- source/core/texture2d.cpp | 10 ++-------- source/core/texture3d.cpp | 8 -------- source/core/texturecube.cpp | 10 ---------- 6 files changed, 11 insertions(+), 57 deletions(-) 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<