X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture.cpp;h=719d4a56ac029218cbd176ac076644865fc20c72;hp=820dd10fd90318c64278ae9b0aed66cf227d8743;hb=0cacf19c2e6aaa182ae0fcc7dfaae345aedd0e74;hpb=7af837734a28a14b3e24a421187d12ecd16572d0 diff --git a/source/texture.cpp b/source/texture.cpp index 820dd10f..719d4a56 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -63,6 +63,7 @@ Texture::Texture(GLenum t, ResourceManager *m): ifmt(RGB), min_filter(NEAREST_MIPMAP_LINEAR), mag_filter(LINEAR), + mipmap_levels(0), max_anisotropy(1.0f), wrap_s(REPEAT), wrap_t(REPEAT), @@ -178,6 +179,8 @@ void Texture::update_parameter(int mask) const glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle_orders+swizzle*4); } } + if(mask&MIPMAP_LEVELS) + set_parameter_i(GL_TEXTURE_MAX_LEVEL, (mipmap_levels ? mipmap_levels-1 : 1000)); } void Texture::set_parameter_i(GLenum param, int value) const @@ -214,6 +217,12 @@ void Texture::set_filter(TextureFilter f) set_mag_filter(f==NEAREST ? NEAREST : LINEAR); } +void Texture::set_mipmap_levels(unsigned l) +{ + mipmap_levels = l; + update_parameter(MIPMAP_LEVELS); +} + void Texture::set_max_anisotropy(float a) { if(a<1.0f) @@ -403,6 +412,7 @@ void Texture::Loader::init() add("mag_filter", &Loader::mag_filter); add("max_anisotropy", &Loader::max_anisotropy); add("min_filter", &Loader::min_filter); + add("mipmap_levels", &Loader::mipmap_levels); add("wrap", &Loader::wrap); add("wrap_r", &Loader::wrap_r); add("wrap_s", &Loader::wrap_s); @@ -452,6 +462,11 @@ void Texture::Loader::min_filter(TextureFilter f) obj.set_min_filter(f); } +void Texture::Loader::mipmap_levels(unsigned l) +{ + obj.set_mipmap_levels(l); +} + void Texture::Loader::wrap(TextureWrap w) { obj.set_wrap(w);