3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
15 void Texture::bind() const
18 throw InvalidState("Attempt to bind a texture without target");
20 const Texture *cur=TexUnit::current().get_texture();
21 if(cur && cur->target!=target)
22 glDisable(cur->target);
23 if(!cur || cur->target!=target)
25 glBindTexture(target, id);
26 TexUnit::current().set_texture(this);
29 void Texture::parameter(GLenum param, int value)
33 glTexParameteri(target, param, value);
36 void Texture::parameter(GLenum param, float value)
40 glTexParameterf(target, param, value);
45 glDeleteTextures(1, &id);
48 void Texture::unbind()
50 const Texture *cur=TexUnit::current().get_texture();
54 glBindTexture(cur->target, 0);
55 glDisable(cur->target);
56 TexUnit::current().set_texture(0);
62 glGenTextures(1, &id);
65 void Texture::maybe_bind() const
67 if(TexUnit::current().get_texture()!=this)