X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Ftexture.h;h=48f551f0ae0d5ea591c984aeb49634a0742763b4;hb=c6c4fc39952e372eba1f44f2bc504428140f3d0e;hp=cccf35b038a461e5d3335dca0ca1d9b050d5f4c7;hpb=84bc56b96c21c831104a22e0cbd0f3b72ab5d8c3;p=libs%2Fgl.git diff --git a/source/texture.h b/source/texture.h index cccf35b0..48f551f0 100644 --- a/source/texture.h +++ b/source/texture.h @@ -1,7 +1,16 @@ +/* $Id$ + +This file is part of libmspgl +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GL_TEXTURE_H_ #define MSP_GL_TEXTURE_H_ -#include +#include +#include +#include "gl.h" #include "types.h" namespace Msp { @@ -17,22 +26,34 @@ enum TextureFilter LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR }; -enum TextureFormat -{ - LUMINANCE8, - LUMINANCE8_ALPHA8, - RGB8, - RGBA8, - BGR8, - BGRA8 -}; +std::istream &operator>>(std::istream &, TextureFilter &); + +/** +Base class for textures. This class only defines operations common for all +texture types and is not instantiable. For specifying images for textures, see +one of the dimensioned texture classes. +*/ class Texture { +protected: + class Loader: public DataFile::Loader + { + protected: + Texture &tex; + + public: + Loader(Texture &); + void min_filter(TextureFilter); + void mag_filter(TextureFilter); + void generate_mipmap(bool); + }; + public: ~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); } @@ -41,6 +62,7 @@ public: uint get_id() const { return id; } static void unbind(); + static void unbind_from(unsigned); protected: uint id; GLenum target;