image(img, srgb);
}
-void Texture::bind_to(unsigned i) const
+void Texture::bind_to(unsigned i, bool legacy) const
{
if(!id)
{
TexUnit &unit = TexUnit::get_unit(i);
const Texture *old = unit.get_texture();
- if(unit.set_texture(this))
+ bool old_legacy = unit.get_texture_legacy();
+ if(unit.set_texture(this, legacy))
{
if(manager)
manager->resource_used(*this);
- if(ARB_direct_state_access && !unit.supports_legacy())
+ 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)
+ if(old && old->target!=target && old_legacy)
glDisable(old->target);
- if((!old || old->target!=target))
+ if((!old || old->target!=target) && legacy)
glEnable(target);
}
glBindTexture(target, id);
{
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 && !unit.supports_legacy())
+ if(ARB_direct_state_access && !legacy)
glBindTextureUnit(i, 0);
else
{
unit.bind();
glBindTexture(cur->target, 0);
- if(unit.supports_legacy())
+ if(unit.supports_legacy() && legacy)
glDisable(cur->target);
}
}