+ wrap_r = w;
+ update_parameter(WRAP_R);
+}
+
+void Texture::set_generate_mipmap(bool gm)
+{
+ if(gm)
+ static Require _req(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_to(unsigned i) const
+{
+ TexUnit &unit = TexUnit::get_unit(i);
+ const Texture *cur = unit.get_texture();
+ if(unit.set_texture(this))
+ {
+ unit.bind();
+ if(cur && cur->target!=target)
+ glDisable(cur->target);
+ if(!cur || cur->target!=target)
+ glEnable(target);
+ glBindTexture(target, id);
+
+ if(dirty_params)
+ {
+ update_parameter(dirty_params);
+ dirty_params = 0;
+ }
+ }
+}
+
+const Texture *Texture::current(unsigned i)
+{
+ return TexUnit::get_unit(i).get_texture();
+}
+
+void Texture::unbind_from(unsigned i)
+{
+ TexUnit &unit = TexUnit::get_unit(i);
+ const Texture *cur = unit.get_texture();
+ if(unit.set_texture(0))
+ {
+ unit.bind();
+ glBindTexture(cur->target, 0);
+ glDisable(cur->target);
+ }