+void Texture::bind_to(unsigned i) const
+{
+ TexUnit::activate(i);
+ bind();
+}
+
+const Texture *Texture::current()
+{
+ return TexUnit::current().get_texture();
+}
+
+void Texture::unbind()
+{
+ const Texture *cur = TexUnit::current().get_texture();
+ if(!cur)
+ return;
+
+ glBindTexture(cur->target, 0);
+ glDisable(cur->target);
+ TexUnit::current().set_texture(0);
+}
+
+void Texture::unbind_from(unsigned i)
+{
+ TexUnit::activate(i);
+ unbind();
+}
+
+
+Texture::Loader::Loader(Texture &t):
+ DataFile::ObjectLoader<Texture>(t)
+{
+ add("min_filter", &Loader::min_filter);
+ add("mag_filter", &Loader::mag_filter);
+ add("generate_mipmap", &Loader::generate_mipmap);
+}
+
+void Texture::Loader::min_filter(TextureFilter f)
+{
+ obj.set_min_filter(f);
+}
+
+void Texture::Loader::mag_filter(TextureFilter f)
+{
+ obj.set_mag_filter(f);
+}
+
+void Texture::Loader::generate_mipmap(bool gm)
+{
+ obj.set_generate_mipmap(gm);
+}