00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GLIFT_TEXSTATE_H_
00021 #define GLIFT_TEXSTATE_H_
00022
00023 #include "../core/gliftObject.h"
00024 #include <GL/glew.h>
00025 #include "../state/stateGLI.h"
00026 #include <mathGutz.h>
00027 #include <vector>
00028
00029 namespace glift {
00030
00031
00032 class TexState;
00033 typedef std::vector<TexState> VecTexState;
00034 typedef std::vector<TexState*> VecTexStateP;
00035
00036 class TexObjState;
00037 typedef std::vector<TexObjState> VecTexOState;
00038 typedef std::vector<TexObjState*> VecTexOStateP;
00039
00040 class TexUnitState;
00041 typedef std::vector<TexUnitState> VecTexUState;
00042 typedef std::vector<TexUnitState*> VecTexUStateP;
00043
00044
00045
00046
00047
00048 class EdgeModeTex;
00049 class FilterTex;
00050 class MipMapTex;
00051 class FuncTex;
00052 class CoordGenTex;
00053
00054 extern const EdgeModeTex *TS_S_CLAMP, *TS_T_CLAMP, *TS_R_CLAMP,
00055 *TS_S_CLAMP_TO_EDGE, *TS_T_CLAMP_TO_EDGE, *TS_R_CLAMP_TO_EDGE,
00056 *TS_S_REPEAT, *TS_T_REPEAT, *TS_R_REPEAT;
00057 extern const FilterTex *TS_NEAREST, *TS_LINEAR;
00058 extern const MipMapTex *TS_NEAREST_MIPMAP_NEAREST, *TS_LINEAR_MIPMAP_NEAREST, *TS_LINEAR_MIPMAP_LINEAR;
00059 extern const FuncTex *TS_MODULATE, *TS_REPLACE, *TS_DECAL;
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 class _export_ TexState : public GliftObject
00095 {
00096 public:
00097 virtual ~TexState() {}
00098 virtual void bind( GLenum texType ) const = 0;
00099 virtual void release() const {}
00100 };
00101
00102
00103
00104
00105
00106 class _export_ TexObjState : public TexState
00107 {
00108 public:
00109 virtual ~TexObjState() {}
00110 virtual void bind( GLenum texType ) const = 0;
00111 virtual void release() const {}
00112 };
00113
00114
00115
00116
00117
00118 class _export_ TexUnitState : public TexState
00119 {
00120 public:
00121 virtual ~TexUnitState() {}
00122 virtual void bind( GLenum texType ) const = 0;
00123 virtual void release() const {}
00124 };
00125
00126
00127
00128
00129
00130 class _export_ EdgeModeTex : public TexObjState
00131 {
00132 public:
00133 EdgeModeTex( GLenum coord, GLenum edgeMode );
00134 virtual void bind( GLenum texType ) const;
00135
00136
00137 void edgeMode( GLenum mode ) {m_edgeMode = mode;}
00138
00139 private:
00140 GLenum m_coord;
00141 GLenum m_edgeMode;
00142
00143 void checkInput();
00144 };
00145
00146
00147
00148
00149
00150
00151 class _export_ FilterTex : public TexObjState
00152 {
00153 public:
00154 FilterTex( GLenum minFilter, GLenum magFilter );
00155 virtual void bind( GLenum texType ) const;
00156
00157
00158 void minFilter( GLenum filter ) {m_minFilter=filter;}
00159 void magFilter( GLenum filter ) {m_magFilter=filter;}
00160
00161 private:
00162 GLenum m_minFilter;
00163 GLenum m_magFilter;
00164
00165 void checkInput( GLenum minFilter, GLenum magFilter );
00166 };
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 class _export_ MipMapTex : public TexObjState
00182 {
00183 public:
00184 MipMapTex( GLenum minFilter, GLenum magFilter, bool autoMipGen=false );
00185 MipMapTex( GLenum minFilter, GLenum magFilter, bool autoMipGen,
00186 int minLevel, int maxLevel, float minLOD, float maxLOD );
00187
00188 virtual void bind( GLenum texType ) const;
00189 virtual void release() const;
00190
00191
00192 bool autoMipGen() const {return m_autoMipGen;}
00193 int minLevel() const {return m_minLevel;}
00194 int maxLevel() const {return m_maxLevel;}
00195 float minLOD() const {return m_minLOD;}
00196 float maxLOD() const {return m_minLOD;}
00197
00198 void minFilter( GLenum filt){m_minFilter = filt;}
00199 void magFilter( GLenum filt){m_magFilter = filt;}
00200 void autoMipGen( bool val ) {m_autoMipGen= val; }
00201 void minLevel( int val ) {m_minLevel = val; }
00202 void maxLevel( int val ) {m_maxLevel = val; }
00203 void minLOD( float val ) {m_minLOD = val; }
00204 void maxLOD( float val ) {m_maxLOD = val; }
00205
00206 private:
00207 const int m_MIN_LEVEL;
00208 const int m_MAX_LEVEL;
00209 const float m_MIN_LOD;
00210 const float m_MAX_LOD;
00211
00212 GLenum m_minFilter;
00213 GLenum m_magFilter;
00214 bool m_autoMipGen;
00215 int m_minLevel;
00216 int m_maxLevel;
00217 float m_minLOD;
00218 float m_maxLOD;
00219
00220 void checkInput( GLenum minFilter, GLenum magFilter );
00221 };
00222
00223
00224
00225
00226
00227 class _export_ FuncTex : public TexUnitState
00228 {
00229 public:
00230 FuncTex( GLenum texFunc );
00231 FuncTex( const gutz::vec4f& blendColor );
00232
00233 virtual void bind( GLenum texType ) const;
00234
00235 gutz::vec4f color() const {return m_blendColor;}
00236 void color( const gutz::vec4f& val ) {m_blendColor = val;}
00237 void texFunc( GLenum mode ) {m_texFunc = mode;}
00238
00239 private:
00240 GLenum m_texFunc;
00241 gutz::vec4f m_blendColor;
00242 };
00243
00244
00245
00246
00247
00248 class _export_ PriorityTex : public TexObjState
00249 {
00250 public:
00251 PriorityTex( GLfloat priority );
00252 virtual void bind( GLenum texType ) const;
00253
00254 GLfloat priority() const {return m_priority;}
00255 void priority( GLfloat val ) {m_priority = val;}
00256
00257 private:
00258 GLfloat m_priority;
00259 };
00260
00261
00262
00263
00264 class _export_ BorderTex : public TexObjState
00265 {
00266 public:
00267 BorderTex( const gutz::vec4f& color );
00268
00269 virtual void bind( GLenum texType ) const;
00270
00271 gutz::vec4f color() const {return m_color;}
00272 void color( const gutz::vec4f& col ) {m_color = col;}
00273
00274 private:
00275 gutz::vec4f m_color;
00276 };
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 class _export_ CoordGenTex : public TexUnitState
00289 {
00290 public:
00291 CoordGenTex( GLenum coord, GLenum genMode );
00292 CoordGenTex( GLenum coord, GLenum genMode, const gutz::vec4f& planeCoeff, const VecStateP& state=VecStateP() );
00293
00294 virtual void bind( GLenum texType ) const;
00295 virtual void release() const;
00296
00297
00298 gutz::vec4f plane() const {return m_plane;}
00299
00300
00301 void plane( const gutz::vec4f& planeCoeff ) {m_plane = planeCoeff;}
00302 void genMode( GLenum mode ) {m_genMode = mode;}
00303
00304 private:
00305 GLenum m_coord;
00306 GLenum m_genMode;
00307 gutz::vec4f m_plane;
00308 GLenum m_coordGen;
00309 VecStateP m_state;
00310
00311 void checkInput();
00312 };
00313
00314 }
00315
00316 #endif