X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture.h;h=848517eb45c99da20a67c8261ed81488b7902ea3;hb=b617c5d7b5283ad260a77f01e42e6170cabbc03d;hp=55eda001a79ec0b12dc3c1e52628327653733365;hpb=f098a871fc6dc7b61a5aca5581fa327e4124c036;p=libs%2Fgl.git diff --git a/source/texture.h b/source/texture.h index 55eda001..848517eb 100644 --- a/source/texture.h +++ b/source/texture.h @@ -8,8 +8,9 @@ Distributed under the LGPL #ifndef MSP_GL_TEXTURE_H_ #define MSP_GL_TEXTURE_H_ -#include -#include "types.h" +#include +#include +#include "gl.h" namespace Msp { namespace GL { @@ -24,32 +25,42 @@ 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::ObjectLoader + { + 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); } void set_mag_filter(TextureFilter f) { parameter(GL_TEXTURE_MAG_FILTER, f); } GLenum get_target() const { return target; } - uint get_id() const { return id; } + unsigned get_id() const { return id; } static void unbind(); + static void unbind_from(unsigned); protected: - uint id; + unsigned id; GLenum target; Texture();