From: Mikko Rasa Date: Sun, 1 Jul 2018 09:15:17 +0000 (+0300) Subject: Use DSA for binding textures if available X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7a2427020ec6ead73258aeb326dfb7e0121520f9;p=libs%2Fgl.git Use DSA for binding textures if available --- diff --git a/source/texture.cpp b/source/texture.cpp index fb409e89..f095fe98 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -321,15 +321,20 @@ void Texture::bind_to(unsigned i) const if(manager) manager->resource_used(*this); - unit.bind(); - if(unit.supports_legacy()) + if(ARB_direct_state_access && !unit.supports_legacy()) + glBindTextureUnit(i, id); + else { - if(old && old->target!=target) - glDisable(old->target); - if(!old || old->target!=target) - glEnable(target); + unit.bind(); + if(unit.supports_legacy()) + { + if(old && old->target!=target) + glDisable(old->target); + if((!old || old->target!=target)) + glEnable(target); + } + glBindTexture(target, id); } - glBindTexture(target, id); if(dirty_params) { @@ -350,10 +355,15 @@ void Texture::unbind_from(unsigned i) const Texture *cur = unit.get_texture(); if(unit.set_texture(0)) { - unit.bind(); - glBindTexture(cur->target, 0); - if(unit.supports_legacy()) - glDisable(cur->target); + if(ARB_direct_state_access && !unit.supports_legacy()) + glBindTextureUnit(i, 0); + else + { + unit.bind(); + glBindTexture(cur->target, 0); + if(unit.supports_legacy()) + glDisable(cur->target); + } } }