From: Mikko Rasa Date: Thu, 3 Oct 2013 21:21:26 +0000 (+0300) Subject: Add a shortcut for specifying both texture filters X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=7857d9df8852071e404a63988f6ad3ddb8f70916 Add a shortcut for specifying both texture filters --- diff --git a/source/texture.cpp b/source/texture.cpp index 3bd1df67..aeea2818 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -101,6 +101,12 @@ void Texture::set_mag_filter(TextureFilter f) update_parameter(MAG_FILTER); } +void Texture::set_filter(TextureFilter f) +{ + set_min_filter(f); + set_mag_filter(f==NEAREST ? NEAREST : LINEAR); +} + void Texture::set_max_anisotropy(float a) { if(a<1.0f) @@ -209,6 +215,7 @@ void Texture::unbind_from(unsigned i) Texture::Loader::Loader(Texture &t): DataFile::ObjectLoader(t) { + add("filter", &Loader::filter); add("max_anisotropy", &Loader::max_anisotropy); add("generate_mipmap", &Loader::generate_mipmap); add("mag_filter", &Loader::mag_filter); @@ -219,6 +226,11 @@ Texture::Loader::Loader(Texture &t): add("wrap_t", &Loader::wrap_t); } +void Texture::Loader::filter(TextureFilter f) +{ + obj.set_filter(f); +} + void Texture::Loader::generate_mipmap(bool gm) { obj.set_generate_mipmap(gm); diff --git a/source/texture.h b/source/texture.h index af0844c5..6b8117fe 100644 --- a/source/texture.h +++ b/source/texture.h @@ -71,6 +71,7 @@ protected: public: Loader(Texture &); private: + void filter(TextureFilter); void generate_mipmap(bool); void mag_filter(TextureFilter); void max_anisotropy(float); @@ -118,6 +119,11 @@ protected: public: void set_min_filter(TextureFilter); void set_mag_filter(TextureFilter); + + /** Sets filter for both minification and magnification. Since mipmapping + is not applicable to magnification, LINEAR is used instead. */ + void set_filter(TextureFilter); + void set_max_anisotropy(float); /** Sets the wrapping mode for all coordinates. */