X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture.h;h=79d79dbd68fbc8c8908b04f180501c6335b783ab;hb=922fac753e31d97fc88daa166e93e4c5572bd2ba;hp=30ad484cbc29835108788add581d54ad48791fd1;hpb=e003d7a1497dad3b13e4e88e681f8fa2afc40c83;p=libs%2Fgl.git diff --git a/source/texture.h b/source/texture.h index 30ad484c..79d79dbd 100644 --- a/source/texture.h +++ b/source/texture.h @@ -4,6 +4,7 @@ #include #include "gl.h" #include "predicate.h" +#include "resource.h" namespace Msp { namespace GL { @@ -63,15 +64,24 @@ texture to be usable. If texture coordinates fall outside of the principal range of the texture, wrapping is applied. The default for all directions is REPEAT. */ -class Texture +class Texture: public Resource { protected: - class Loader: public DataFile::ObjectLoader + class Loader: public DataFile::CollectionObjectLoader { + protected: + bool srgb; + public: Loader(Texture &); + Loader(Texture &, Collection &); + private: + void init(); + + void filter(TextureFilter); void generate_mipmap(bool); void mag_filter(TextureFilter); + void max_anisotropy(float); void min_filter(TextureFilter); void wrap(TextureWrap); void wrap_r(TextureWrap); @@ -88,13 +98,15 @@ protected: WRAP_R = 16, GENERATE_MIPMAP = 32, COMPARE = 64, - COMPARE_FUNC = 128 + COMPARE_FUNC = 128, + MAX_ANISOTROPY = 256 }; unsigned id; GLenum target; TextureFilter min_filter; TextureFilter mag_filter; + float max_anisotropy; TextureWrap wrap_s; TextureWrap wrap_t; TextureWrap wrap_r; @@ -103,7 +115,7 @@ protected: Predicate cmp_func; mutable int dirty_params; - Texture(GLenum); + Texture(GLenum, ResourceManager * = 0); Texture(const Texture &); Texture &operator=(const Texture &); public: @@ -115,6 +127,12 @@ 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. */ void set_wrap(TextureWrap); @@ -138,12 +156,14 @@ public: GLenum get_target() const { return target; } unsigned get_id() const { return id; } - void bind() const; + void bind() const { bind_to(0); } void bind_to(unsigned) const; - static const Texture *current(); - static void unbind(); + static const Texture *current(unsigned = 0); + static void unbind() { unbind_from(0); } static void unbind_from(unsigned); + + virtual UInt64 get_data_size() const { return 0; } }; } // namespace GL