X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fsampler.h;h=b2011d3bed3db8dc7631fc3224c37c6011d39c3f;hb=bae374a3cda6a1b59f36016624ef518bf2676355;hp=bb02269f8c0ec9bcfd4408b3e48fa49702b90e06;hpb=dbc91b65728ab9c0e574bb1127cfe4d2da55de7f;p=libs%2Fgl.git diff --git a/source/core/sampler.h b/source/core/sampler.h index bb02269f..b2011d3b 100644 --- a/source/core/sampler.h +++ b/source/core/sampler.h @@ -3,7 +3,6 @@ #include #include "color.h" -#include "gl.h" #include "predicate.h" namespace Msp { @@ -12,42 +11,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 @@ -65,6 +62,8 @@ wrapping is applied. The default for all directions is REPEAT. */ class Sampler { + friend class PipelineState; + public: class Loader: public DataFile::ObjectLoader { @@ -114,10 +113,7 @@ public: Sampler(); private: - 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; + void update() const; public: void set_min_filter(TextureFilter); @@ -155,18 +151,15 @@ 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 set_debug_name(const std::string &); }; bool is_mipmapped(TextureFilter); +unsigned get_gl_filter(TextureFilter); +unsigned get_gl_wrap(TextureWrap); void operator>>(const LexicalConverter &, TextureFilter &); void operator>>(const LexicalConverter &, TextureWrap &);