+ mag_filter = f;
+ update_parameter(MAG_FILTER);
+}
+
+void Texture::set_wrap(TextureWrap w)
+{
+ set_wrap_s(w);
+ set_wrap_t(w);
+ set_wrap_r(w);
+}
+
+void Texture::set_wrap_s(TextureWrap w)
+{
+ wrap_s = w;
+ update_parameter(WRAP_S);
+}
+
+void Texture::set_wrap_t(TextureWrap w)
+{
+ wrap_t = w;
+ update_parameter(WRAP_T);
+}
+
+void Texture::set_wrap_r(TextureWrap w)
+{
+ wrap_r = w;
+ update_parameter(WRAP_R);
+}
+
+void Texture::set_generate_mipmap(bool gm)
+{
+ if(gm)
+ static RequireExtension _ext("GL_SGIS_generate_mipmap");
+ gen_mipmap = gm;
+ update_parameter(GENERATE_MIPMAP);
+}
+
+void Texture::set_compare_enabled(bool c)
+{
+ compare = c;
+ update_parameter(COMPARE);
+}
+
+void Texture::set_compare_func(Predicate f)
+{
+ cmp_func = f;
+ update_parameter(COMPARE_FUNC);
+}
+
+void Texture::bind() const
+{
+ const Texture *cur = TexUnit::current().get_texture();
+ if(cur!=this)
+ {
+ if(cur && cur->target!=target)
+ glDisable(cur->target);
+ if(!cur || cur->target!=target)
+ glEnable(target);
+
+ glBindTexture(target, id);
+ TexUnit::current().set_texture(this);
+
+ if(dirty_params)
+ {
+ update_parameter(dirty_params);
+ dirty_params = 0;
+ }
+ }
+}
+
+void Texture::bind_to(unsigned i) const
+{
+ TexUnit::activate(i);
+ bind();
+}
+
+const Texture *Texture::current()
+{
+ return TexUnit::current().get_texture();