X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fsampler.h;h=c79068775b144499943196b316dc0f8f0406f75b;hb=34d956d6890ce7070741667d4864fa798883da72;hp=43d1e5412a2fe3df0bb732ac42bc6b1344e1b003;hpb=6065f6622cc275dc0b20baaf7c267e71169d18f3;p=libs%2Fgl.git diff --git a/source/core/sampler.h b/source/core/sampler.h index 43d1e541..c7906877 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,38 +12,38 @@ 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 }; @@ -61,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 { @@ -96,22 +98,17 @@ private: COMPARE = 128 }; - unsigned id; - TextureFilter min_filter; - TextureFilter mag_filter; - float max_anisotropy; - TextureWrap wrap_s; - TextureWrap wrap_t; - TextureWrap wrap_r; - Color border_color; - bool compare; - Predicate cmp_func; - mutable int dirty_params; - -public: - Sampler(); + TextureFilter min_filter = NEAREST_MIPMAP_LINEAR; + TextureFilter mag_filter = LINEAR; + float max_anisotropy = 1.0f; + TextureWrap wrap_s = REPEAT; + TextureWrap wrap_t = REPEAT; + TextureWrap wrap_r = REPEAT; + Color border_color = { 0.0f, 0.0f, 0.0f, 0.0f }; + bool compare = false; + Predicate cmp_func = LEQUAL; + mutable int dirty_params = 0; -private: void update() const; public: @@ -152,9 +149,7 @@ public: void refresh() const { if(dirty_params) update(); } - unsigned get_id() const { return id; } - - void set_debug_name(const std::string &); + using SamplerBackend::set_debug_name; };