HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RE_TextureFilter.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_TextureFilter.h ( RE Library, C++)
7  *
8  * COMMENTS:
9  * This class contains simple filter information used for textures.
10  * The GPU does the actual filtering.
11  */
12 #ifndef RE_TextureFilter_h
13 #define RE_TextureFilter_h
14 
15 #include "RE_API.h"
16 #include <UT/UT_Color.h>
17 #include "RE_TextureTypes.h"
18 
19 
21 {
22 public:
24 
25  RE_TextureFilter &operator=(const RE_TextureFilter &filter);
26  bool operator==(const RE_TextureFilter &filter) const;
27 
28  void setMinFilter(RE_TexFiltType t );
29  RE_TexFiltType getMinFilter() const;
30 
31  // Filter to use when displaying the texture at greater than 100% zoom
32  void setMagFilter(RE_TexFiltType t );
33  RE_TexFiltType getMagFilter() const;
34 
35  // Anisotropic filtering. Acceptable values are pow2 up to the GL max.
36  void setMaxAnisotropy(int atf);
37  int getMaxAnisotropy() const;
38 
39  // Fixed bias value that is added to the level-of-detail parameter for
40  // the texture before texture sampling (when mipmapping).
41  void setLodBias(float bias);
42  float getLodBias() const;
43 
44  // Texture wrapping - clamp or repeat (true). Not all dimension may be used.
45  void setTextureWrap(RE_TexClampType wrap_s,
48  RE_TexClampType getWrapS() const;
49  RE_TexClampType getWrapT() const;
50  RE_TexClampType getWrapR() const;
51  bool isWrapSet() const;
52 
53  // For RE_CLAMP_BORDER, this defines the border color, normally (0,0,0,0).
54  void setBorder(RE_TextureBorder border,
55  const UT_Vector4F *color_alpha = NULL);
56  const UT_Vector4F &getBorderColor() const;
57 
58  // Sets all the filtering options to invalid values.
59  void invalidate();
60 
61 private:
62  RE_TexFiltType myMinFilter;
63  RE_TexFiltType myMagFilter;
64  int myTextureAnisotropy;
65  UT_Vector4F myBorder;
66  float myLodBias;
67  unsigned short myWrapS:3, myWrapT:3, myWrapR:3;
68 };
69 
71  : myMinFilter(RE_FILT_LINEAR),
72  myMagFilter(RE_FILT_LINEAR),
73  myWrapS(RE_CLAMP_REPEAT),
74  myWrapT(RE_CLAMP_REPEAT),
75  myWrapR(RE_CLAMP_REPEAT),
76  myTextureAnisotropy(1),
77  myBorder(0,0,0,0),
78  myLodBias(0.0f)
79 {
80 }
81 
82 inline void
84 {
85  myMinFilter = t;
86 }
87 
88 inline RE_TexFiltType
90 {
91  return myMinFilter;
92 }
93 
94 inline void
96 {
97  myMagFilter = t;
98 }
99 
100 inline RE_TexFiltType
102 {
103  return myMagFilter;
104 }
105 
106 inline void
108 {
109  myTextureAnisotropy = ta;
110 }
111 
112 inline int
114 {
115  return myTextureAnisotropy;
116 }
117 
118 inline void
120 {
121  myLodBias = bias;
122 }
123 
124 inline float
126 {
127  return myLodBias;
128 }
129 
130 inline void
132  RE_TexClampType t,
134 {
135  myWrapS = s;
136  myWrapT = t;
137  myWrapR = r;
138 }
139 
140 inline RE_TexClampType
142 {
143  return RE_TexClampType(myWrapS);
144 }
145 
146 inline RE_TexClampType
148 {
149  return RE_TexClampType(myWrapT);
150 }
151 
152 inline RE_TexClampType
154 {
155  return RE_TexClampType(myWrapR);
156 }
157 
158 inline RE_TextureFilter &
160 {
161  myWrapS = filter.myWrapS;
162  myWrapT = filter.myWrapT;
163  myWrapR = filter.myWrapR;
164  myMinFilter = filter.myMinFilter;
165  myMagFilter = filter.myMagFilter;
166  myTextureAnisotropy = filter.myTextureAnisotropy;
167  myBorder = filter.myBorder;
168 
169  return *this;
170 }
171 
172 inline bool
174 {
175  return (myWrapS == filter.myWrapS &&
176  myWrapT == filter.myWrapT &&
177  myWrapR == filter.myWrapR &&
178  myMinFilter == filter.myMinFilter &&
179  myMagFilter == filter.myMagFilter &&
180  myBorder == filter.myBorder &&
181  myTextureAnisotropy == filter.myTextureAnisotropy);
182 }
183 
184 inline void
186 {
187  myMinFilter = RE_FILT_MAX_FILTERS;
188  myMagFilter = RE_FILT_MAX_FILTERS;
189  myWrapS = RE_TEXTURE_BAD_WRAPPING;
190  myWrapT = RE_TEXTURE_BAD_WRAPPING;
191  myWrapR = RE_TEXTURE_BAD_WRAPPING;
192  myBorder.assign(-1,-1,-1,-1);
193  myTextureAnisotropy = 0;
194 }
195 
196 inline bool
198 {
199  return (myWrapS != RE_TEXTURE_BAD_WRAPPING &&
200  myWrapT != RE_TEXTURE_BAD_WRAPPING &&
201  myWrapR != RE_TEXTURE_BAD_WRAPPING);
202 }
203 
204 inline void
206  const UT_Vector4F *color)
207 {
208  switch(border)
209  {
210  case RE_TEX_BORDER_ZERO:
211  myBorder.assign(0,0,0,0); break;
212  case RE_TEX_BORDER_BLACK:
213  myBorder.assign(0,0,0,1); break;
214  case RE_TEX_BORDER_WHITE:
215  myBorder.assign(1,1,1,1); break;
216  case RE_TEX_BORDER_COLOR:
217  UT_ASSERT(color);
218  myBorder = *color;
219  break;
220  }
221 }
222 
223 inline const UT_Vector4F &
225 {
226  return myBorder;
227 }
228 
229 #endif
#define RE_API
Definition: RE_API.h:10
RE_TextureFilter & operator=(const RE_TextureFilter &filter)
GLuint color
Definition: glcorearb.h:1260
void setMaxAnisotropy(int atf)
float getLodBias() const
RE_TexFiltType getMagFilter() const
RE_TexFiltType
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
GLfloat f
Definition: glcorearb.h:1925
#define RE_TEXTURE_BAD_WRAPPING
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
void setMinFilter(RE_TexFiltType t)
void setLodBias(float bias)
RE_TexClampType
void setTextureWrap(RE_TexClampType wrap_s, RE_TexClampType wrap_t=RE_CLAMP_EDGE, RE_TexClampType wrap_r=RE_CLAMP_EDGE)
RE_TextureBorder
int getMaxAnisotropy() const
void assign(T xx=0.0f, T yy=0.0f, T zz=0.0f, T ww=1.0f)
Set the values of the vector components.
Definition: UT_Vector4.h:395
GLint GLint GLsizei GLint border
Definition: glcorearb.h:107
RE_TexClampType getWrapR() const
RE_TexClampType getWrapS() const
void setMagFilter(RE_TexFiltType t)
RE_TexFiltType getMinFilter() const
GLboolean r
Definition: glcorearb.h:1221
bool operator==(const RE_TextureFilter &filter) const
const UT_Vector4F & getBorderColor() const
RE_TexClampType getWrapT() const
bool isWrapSet() const
void setBorder(RE_TextureBorder border, const UT_Vector4F *color_alpha=NULL)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296