X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fsampler.h;h=bd8db31fdc8f9601f5ac2ac55e9762cead38fef4;hb=160e9eea29bd10034733d59507fa1bcca36be401;hp=79aea8f8b76621f6ed9f5e5f44d0df08bf84aa0d;hpb=96bbfddc653826ee9848c468c53bca024711a6c3;p=libs%2Fgl.git diff --git a/source/core/sampler.h b/source/core/sampler.h index 79aea8f8..bd8db31f 100644 --- a/source/core/sampler.h +++ b/source/core/sampler.h @@ -3,8 +3,8 @@ #include #include "color.h" -#include "gl.h" #include "predicate.h" +#include "sampler_backend.h" namespace Msp { namespace GL { @@ -12,42 +12,40 @@ namespace GL { enum TextureFilter { /// No filtering - NEAREST = GL_NEAREST, + NEAREST, /// Bilinear filtering - LINEAR = GL_LINEAR, + LINEAR, /// Mipmapping without filtering - NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST, + NEAREST_MIPMAP_NEAREST, /// Linear filtering between two mipmap levels - NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR, + NEAREST_MIPMAP_LINEAR, /// Bilinear filtering on the closest mipmap level - LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST, + LINEAR_MIPMAP_NEAREST, /// Trilinear filtering between two mipmap levels - LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR + LINEAR_MIPMAP_LINEAR }; enum TextureWrap { /// Tile the texture infinitely - REPEAT = GL_REPEAT, + REPEAT, /// Extend the texels at the edge of the texture to infinity - CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE, + CLAMP_TO_EDGE, /// Sampling outside the texture will return border color - CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER, + CLAMP_TO_BORDER, /// Tile the texture, with every other repetition mirrored - MIRRORED_REPEAT = GL_MIRRORED_REPEAT + MIRRORED_REPEAT }; -class Texture; - /** Samplers are used to access texture data in shaders. To use a sampler with a @@ -63,8 +61,10 @@ for magnification and NEAREST_MIPMAP_LINEAR for minification. If texture coordinates fall outside of the principal range of the texture, wrapping is applied. The default for all directions is REPEAT. */ -class Sampler +class Sampler: public SamplerBackend { + friend SamplerBackend; + public: class Loader: public DataFile::ObjectLoader { @@ -98,8 +98,6 @@ private: COMPARE = 128 }; - unsigned id; - const Texture *owner; TextureFilter min_filter; TextureFilter mag_filter; float max_anisotropy; @@ -113,14 +111,9 @@ private: public: Sampler(); - Sampler(const Texture &); -private: - void init(); - void update_parameter(int) const; - void set_parameter_i(unsigned, int) const; - void set_parameter_f(unsigned, float) const; - void set_parameter_fv(unsigned, const float *) const; +private: + void update() const; public: void set_min_filter(TextureFilter); @@ -158,14 +151,9 @@ public: bool is_compare_enabled() const { return compare; } Predicate get_compare_function() const { return cmp_func; } - void bind() const { bind_to(0); } - void bind_to(unsigned) const; - - static const Sampler *current(unsigned = 0); - static void unbind() { unbind_from(0); } - static void unbind_from(unsigned); + void refresh() const { if(dirty_params) update(); } - void unload(); + using SamplerBackend::set_debug_name; };