]> git.tdb.fi Git - libs/gl.git/commitdiff
Use DSA for binding textures if available
authorMikko Rasa <tdb@tdb.fi>
Sun, 1 Jul 2018 09:15:17 +0000 (12:15 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 1 Jul 2018 09:15:17 +0000 (12:15 +0300)
source/texture.cpp

index fb409e895c7fc3a0d221ee829648024462d76a55..f095fe98aadcb99500ecad562275027453d14dcf 100644 (file)
@@ -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);
+               }
        }
 }