#include <msp/gl/extensions/arb_shadow.h>
#include <msp/gl/extensions/ext_texture_filter_anisotropic.h>
#include <msp/gl/extensions/ext_texture3d.h>
+#include <msp/gl/extensions/khr_debug.h>
#include <msp/strings/format.h>
#include "error.h"
#include "sampler.h"
wrap_s = REPEAT;
wrap_t = REPEAT;
wrap_r = REPEAT;
+ border_color = Color(0.0f, 0.0f, 0.0f, 0.0f);
compare = false;
cmp_func = LEQUAL;
dirty_params = 0;
set_parameter_i(GL_TEXTURE_WRAP_T, wrap_t);
if(mask&WRAP_R)
set_parameter_i(GL_TEXTURE_WRAP_R, wrap_r);
+ if(mask&BORDER_COLOR)
+ set_parameter_fv(GL_TEXTURE_BORDER_COLOR, &border_color.r);
if(mask&COMPARE)
{
set_parameter_i(GL_TEXTURE_COMPARE_MODE, (compare ? GL_COMPARE_R_TO_TEXTURE : GL_NONE));
glTexParameterf(owner->get_target(), param, value);
}
+void Sampler::set_parameter_fv(unsigned param, const float *value) const
+{
+ if(id)
+ glSamplerParameterfv(id, param, value);
+ else if(ARB_direct_state_access)
+ glTextureParameterfv(owner->get_id(), param, value);
+ else
+ glTexParameterfv(owner->get_target(), param, value);
+}
+
void Sampler::set_min_filter(TextureFilter f)
{
min_filter = f;
update_parameter(WRAP_R);
}
+void Sampler::set_border_color(const Color &c)
+{
+ border_color = c;
+ update_parameter(BORDER_COLOR);
+}
+
void Sampler::disable_compare()
{
compare = false;
}
}
+void Sampler::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ if(id && KHR_debug)
+ glObjectLabel(GL_SAMPLER, id, name.size(), name.c_str());
+#else
+ (void)name;
+#endif
+}
+
Sampler::Loader::Loader(Sampler &s):
DataFile::ObjectLoader<Sampler>(s)
{
+ add("border_color", &Loader::border_color);
+ add("compare", &Loader::compare);
add("filter", &Loader::filter);
add("mag_filter", &Loader::mag_filter);
add("max_anisotropy", &Loader::max_anisotropy);
add("wrap_t", &Loader::wrap_t);
}
+void Sampler::Loader::border_color(float r, float g, float b, float a)
+{
+ obj.set_border_color(Color(r, g, b, a));
+}
+
+void Sampler::Loader::compare(Predicate c)
+{
+ obj.set_compare(c);
+}
+
void Sampler::Loader::filter(TextureFilter f)
{
obj.set_filter(f);
tw = REPEAT;
else if(c.get()=="CLAMP_TO_EDGE")
tw = CLAMP_TO_EDGE;
+ else if(c.get()=="CLAMP_TO_BORDER")
+ tw = CLAMP_TO_BORDER;
else if(c.get()=="MIRRORED_REPEAT")
tw = MIRRORED_REPEAT;
else