]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.cpp
Move transform loading to ObjectInstance
[libs/gl.git] / source / texture.cpp
index 820dd10fd90318c64278ae9b0aed66cf227d8743..719d4a56ac029218cbd176ac076644865fc20c72 100644 (file)
@@ -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);