+++ /dev/null
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include <msp/core/error.h>
-#include "texture.h"
-#include "texunit.h"
-
-namespace Msp {
-namespace GL {
-
-void Texture::bind() const
-{
- if(!target)
- 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);
-}
-
-void Texture::parameter(GLenum param, int value)
-{
- maybe_bind();
-
- glTexParameteri(target, param, value);
-}
-
-void Texture::parameter(GLenum param, float value)
-{
- maybe_bind();
-
- glTexParameterf(target, param, value);
-}
-
-Texture::~Texture()
-{
- glDeleteTextures(1, &id);
-}
-
-void Texture::unbind()
-{
- const Texture *cur=TexUnit::current().get_texture();
- if(!cur)
- return;
-
- glBindTexture(cur->target, 0);
- glDisable(cur->target);
- TexUnit::current().set_texture(0);
-}
-
-Texture::Texture():
- target(0)
-{
- glGenTextures(1, &id);
-}
-
-void Texture::maybe_bind() const
-{
- if(TexUnit::current().get_texture()!=this)
- bind();
-}
-
-} // namespace GL
-} // namespace Msp