00001 #ifndef GLT_TEXTURE_H
00002 #define GLT_TEXTURE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00039 #include <glt/config.h>
00040 #include <glt/gl.h>
00041
00042 #include <misc/refcount.h>
00043
00044 #include <iosfwd>
00045 #include <string>
00046
00052 class GltTexture;
00053 typedef ReferenceCountPtr<GltTexture> GltTexturePtr;
00054
00055 class GltTexture
00056 {
00057 public:
00058
00059
00060
00061
00062
00064 GltTexture(const GLenum target = GL_TEXTURE_2D);
00066 ~GltTexture();
00067
00068
00069
00070
00071
00072
00073 private:
00074
00076 GltTexture(const GltTexture &);
00078 GltTexture &operator=(const GltTexture &);
00079
00080 public:
00081
00083 void clear();
00084
00086 bool init(const void *,const bool mipmap = true);
00088 bool init(const GLsizei width,const GLsizei height,const std::string &image,const bool mipmap = true);
00090 bool init(const GLsizei width,const GLsizei height,const byte *image,const GLsizei channels,const bool mipmap = true);
00091
00093 void set() const;
00094
00106 void setWrap(const GLenum s,const GLenum t);
00107
00123 void setFilter(const GLenum min,const GLenum mag);
00124
00126 void setGamma(const real gamma);
00127
00129 void setHSVAdjust(const real hue,const real saturation,const real value);
00130
00131
00132
00133
00134
00136 const GLsizei &width() const;
00137
00139 const GLsizei &height() const;
00140
00142 const GLuint id() const;
00143
00144
00145
00151 typedef enum
00152 {
00153 TEXTURE_TYPE_RGB = 0,
00154 TEXTURE_TYPE_RGBA,
00155 TEXTURE_TYPE_GREY,
00156 TEXTURE_TYPE_GREYA,
00157 TEXTURE_TYPE_ALPHA,
00158 TEXTURE_TYPE_BITMAP,
00159 TEXTURE_TYPE_INDEXED_RGB,
00160 TEXTURE_TYPE_INDEXED_RGBA,
00162
00163
00164 } GltTextureType;
00165
00167 static bool makeHeader(std::string &header,const int type,const int width,const int height,const int alignment,const int compressed);
00169 static void *getHeader(const void * const h,int &type,int &width,int &height,int &alignment,int &compressed);
00170
00171 private:
00172
00173 GLenum _target;
00174
00175 GLint _components;
00176 GLsizei _width;
00177 GLsizei _height;
00178 GLint _border;
00179 GLenum _format;
00180 GLenum _type;
00181 GLint _alignment;
00182
00183 GLenum _wrapS,_wrapT;
00184 GLenum _filterMin,_filterMag;
00185
00186 real _gamma;
00187 real _hue,_saturation,_value;
00188
00189 GLuint _id;
00190 };
00191
00192 #endif