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)
~Texture();
void bind() const;
+ void bind_to(unsigned) const;
void parameter(GLenum, int);
void parameter(GLenum, float);
void set_min_filter(TextureFilter f) { parameter(GL_TEXTURE_MIN_FILTER, f); }