]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.cpp
Drop Renderable::has_pass; renderables are now expected to ignore unknown passes
[libs/gl.git] / source / texture.cpp
index 7ce039acb6df2278ff8c2df8c289e63cfd290820..47b6ba37abb300f8fae19a83be1ace593001362f 100644 (file)
@@ -44,12 +44,21 @@ void Texture::bind() const
                throw InvalidState("Attempt to bind a texture without target");
 
        const Texture *cur=TexUnit::current().get_texture();
-       if(cur && cur->target!=target)
-               glDisable(cur->target);
-       if(!cur || cur->target!=target)
-               glEnable(target);
-       glBindTexture(target, id);
-       TexUnit::current().set_texture(this);
+       if(cur!=this)
+       {
+               if(cur && cur->target!=target)
+                       glDisable(cur->target);
+               if(!cur || cur->target!=target)
+                       glEnable(target);
+               glBindTexture(target, id);
+               TexUnit::current().set_texture(this);
+       }
+}
+
+void Texture::bind_to(unsigned i) const
+{
+       TexUnit::activate(i);
+       bind();
 }
 
 void Texture::parameter(GLenum param, int value)
@@ -82,6 +91,12 @@ void Texture::unbind()
        TexUnit::current().set_texture(0);
 }
 
+void Texture::unbind_from(unsigned i)
+{
+       TexUnit::activate(i);
+       unbind();
+}
+
 Texture::Texture():
        target(0)
 {