X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fsampler.cpp;h=4da13833330dac12eace04b145f9ffacd4a0510b;hp=6f4770acb4e40a73ea6270bfeabcbeeec273fcc8;hb=HEAD;hpb=160e9eea29bd10034733d59507fa1bcca36be401 diff --git a/source/core/sampler.cpp b/source/core/sampler.cpp index 6f4770ac..4da13833 100644 --- a/source/core/sampler.cpp +++ b/source/core/sampler.cpp @@ -1,4 +1,5 @@ #include +#include "device.h" #include "error.h" #include "sampler.h" @@ -7,19 +8,6 @@ using namespace std; namespace Msp { namespace GL { -Sampler::Sampler(): - min_filter(NEAREST_MIPMAP_LINEAR), - mag_filter(LINEAR), - max_anisotropy(1.0f), - 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) -{ } - void Sampler::update() const { SamplerBackend::update(dirty_params); @@ -34,6 +22,8 @@ void Sampler::set_min_filter(TextureFilter f) void Sampler::set_mag_filter(TextureFilter f) { + if(is_mipmapped(f)) + throw invalid_argument("Sampler::set_mag_filter"); mag_filter = f; dirty_params |= MAG_FILTER; } @@ -48,19 +38,14 @@ void Sampler::set_max_anisotropy(float a) { if(a<1.0f) throw invalid_argument("Sampler::set_max_anisotropy"); + if(a>Device::get_current().get_info().limits.max_anisotropy) + throw out_of_range("Sampler::set_max_anisotropy"); bool supported = check_anisotropic(a>1.0f); max_anisotropy = a; if(supported) dirty_params |= MAX_ANISOTROPY; } -void Sampler::set_wrap(TextureWrap w) -{ - set_wrap_s(w); - set_wrap_t(w); - set_wrap_r(w); -} - void Sampler::set_wrap_s(TextureWrap w) { wrap_s = w; @@ -79,6 +64,13 @@ void Sampler::set_wrap_r(TextureWrap w) dirty_params |= WRAP_R; } +void Sampler::set_wrap(TextureWrap w) +{ + set_wrap_s(w); + set_wrap_t(w); + set_wrap_r(w); +} + void Sampler::set_border_color(const Color &c) { border_color = c;