#define MSP_GL_SAMPLER_H_
#include <msp/datafile/objectloader.h>
+#include "color.h"
#include "gl.h"
#include "predicate.h"
/// Extend the texels at the edge of the texture to infinity
CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
+ /// Sampling outside the texture will return border color
+ CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER,
+
/// Tile the texture, with every other repetition mirrored
MIRRORED_REPEAT = GL_MIRRORED_REPEAT
};
private:
void init();
+ void border_color(float, float, float, float);
+ void compare(Predicate);
void filter(TextureFilter);
void mag_filter(TextureFilter);
void max_anisotropy(float);
WRAP_S = 8,
WRAP_T = 16,
WRAP_R = 32,
- COMPARE = 64
+ BORDER_COLOR = 64,
+ COMPARE = 128
};
unsigned id;
- const Texture *owner;
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();
- Sampler(const Texture &);
-private:
- void init();
- void update_parameter(int) const;
+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 set_wrap_t(TextureWrap);
void set_wrap_r(TextureWrap);
+ void set_border_color(const Color &);
+ const Color &get_border_color() const { return border_color; }
+
/** Disables depth comparison. */
void disable_compare();
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;
+ void refresh() const { if(dirty_params) update(); }
- static const Sampler *current(unsigned = 0);
- static void unbind() { unbind_from(0); }
- static void unbind_from(unsigned);
+ unsigned get_id() const { return id; }
- void unload();
+ void set_debug_name(const std::string &);
};