+ static Require _req(ARB_shadow);
+ cmp_func = f;
+ update_parameter(COMPARE_FUNC);
+}
+
+void Texture::load_image(const string &fn, bool srgb)
+{
+ Graphics::Image img;
+ img.load_file(fn);
+
+ image(img, srgb);
+}
+
+void Texture::bind_to(unsigned i, bool legacy) const
+{
+ if(!id)
+ {
+ if(manager)
+ manager->resource_used(*this);
+ if(!id)
+ {
+ unbind_from(i);
+ return;
+ }
+ }
+
+ TexUnit &unit = TexUnit::get_unit(i);
+ const Texture *old = unit.get_texture();
+ bool old_legacy = unit.get_texture_legacy();
+ if(unit.set_texture(this, legacy))
+ {
+ if(manager)
+ manager->resource_used(*this);
+
+ if(ARB_direct_state_access && !old_legacy && (!unit.supports_legacy() || !legacy))
+ glBindTextureUnit(i, id);
+ else
+ {
+ unit.bind();
+ if(unit.supports_legacy())
+ {
+ if(old && old->target!=target && old_legacy)
+ glDisable(old->target);
+ if((!old || old->target!=target) && legacy)
+ 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();
+ bool legacy = unit.get_texture_legacy();
+ if(unit.set_texture(0))
+ {
+ if(ARB_direct_state_access && !legacy)
+ glBindTextureUnit(i, 0);
+ else
+ {
+ unit.bind();
+ glBindTexture(cur->target, 0);
+ if(unit.supports_legacy() && legacy)
+ glDisable(cur->target);
+ }
+ }