#include <msp/datafile/objectloader.h>
#include "color.h"
-#include "gl.h"
#include "predicate.h"
+#include "sampler_backend.h"
namespace Msp {
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
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<Sampler>
{
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;
- void set_parameter_i(unsigned, int) const;
- void set_parameter_f(unsigned, float) const;
- void set_parameter_fv(unsigned, const float *) const;
public:
void set_min_filter(TextureFilter);
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;
};