Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sampler.h
Go to the documentation of this file.
1 
18 #ifndef ION_GFX_SAMPLER_H_
19 #define ION_GFX_SAMPLER_H_
20 
21 #include "ion/base/referent.h"
22 #include "ion/gfx/resourceholder.h"
23 
24 namespace ion {
25 namespace gfx {
26 
29 class ION_API Sampler : public ResourceHolder {
30  public:
32  enum Changes {
33  kAutoMipmappingChanged = kNumBaseChanges,
44  kNumChanges
45  };
46 
56  kNotEqual
57  };
58 
60  enum CompareMode {
62  kNone
63  };
64 
66  enum FilterMode {
73  kLinearMipmapLinear
74  };
75 
77  enum WrapMode {
80  kMirroredRepeat
81  };
82 
83  Sampler();
84 
89  void SetAutogenerateMipmapsEnabled(bool enable) {
90  auto_mipmapping_enabled_.Set(enable);
91  }
94  return auto_mipmapping_enabled_.Get();
95  }
96 
100  compare_mode_.Set(mode);
101  }
102  CompareMode GetCompareMode() const { return compare_mode_.Get(); }
103 
108  compare_function_.Set(func);
109  }
110  CompareFunction GetCompareFunction() const { return compare_function_.Get(); }
111 
113  void SetMaxAnisotropy(float aniso) {
114  max_anisotropy_.Set(aniso);
115  }
117  float GetMaxAnisotropy() const { return max_anisotropy_.Get(); }
118 
120  void SetMinFilter(const FilterMode& mode) {
121  min_filter_.Set(mode);
122  }
124  FilterMode GetMinFilter() const { return min_filter_.Get(); }
125 
127  void SetMagFilter(const FilterMode& mode) {
128  mag_filter_.Set(mode);
129  }
131  FilterMode GetMagFilter() const { return mag_filter_.Get(); }
132 
135  void SetMinLod(float lod) {
136  min_lod_.Set(lod);
137  }
139  float GetMinLod() const { return min_lod_.Get(); }
140 
143  void SetMaxLod(float lod) {
144  max_lod_.Set(lod);
145  }
147  float GetMaxLod() const { return max_lod_.Get(); }
148 
150  void SetWrapR(const WrapMode& mode) {
151  wrap_r_.Set(mode);
152  }
154  WrapMode GetWrapR() const { return wrap_r_.Get(); }
155 
157  void SetWrapS(const WrapMode& mode) {
158  wrap_s_.Set(mode);
159  }
161  WrapMode GetWrapS() const { return wrap_s_.Get(); }
162 
164  void SetWrapT(const WrapMode& mode) {
165  wrap_t_.Set(mode);
166  }
168  WrapMode GetWrapT() const { return wrap_t_.Get(); }
169 
170  protected:
173  ~Sampler() override;
174 
175  private:
176  Field<bool> auto_mipmapping_enabled_;
177  RangedField<float> max_anisotropy_;
178  Field<float> min_lod_;
179  Field<float> max_lod_;
180  RangedField<CompareFunction> compare_function_;
181  RangedField<CompareMode> compare_mode_;
182  RangedField<FilterMode> min_filter_;
183  RangedField<FilterMode> mag_filter_;
184  RangedField<WrapMode> wrap_r_;
185  RangedField<WrapMode> wrap_s_;
186  RangedField<WrapMode> wrap_t_;
187 };
188 
191 
192 } // namespace gfx
193 } // namespace ion
194 
195 #endif // ION_GFX_SAMPLER_H_
bool IsAutogenerateMipmapsEnabled() const
Gets whether this Sampler should use mipmapping. The default is false.
Definition: sampler.h:93
CompareMode
Texture comparison modes for depth textures.
Definition: sampler.h:60
void SetAutogenerateMipmapsEnabled(bool enable)
Sets whether OpenGL should automatically generate mipmaps for this Sampler.
Definition: sampler.h:89
FilterMode GetMinFilter() const
Gets the minification mode. The default is kNearest.
Definition: sampler.h:124
void SetWrapT(const WrapMode &mode)
Sets the wrap along the t-coordinate.
Definition: sampler.h:164
void SetMaxLod(float lod)
Sets the maximum level of detail parameter, which limits the selection of the lowest resolution (high...
Definition: sampler.h:143
void SetMinFilter(const FilterMode &mode)
Sets the minification mode.
Definition: sampler.h:120
float GetMinLod() const
Gets the minimum level of detail parameter. The default is -1000.
Definition: sampler.h:139
WrapMode GetWrapR() const
Gets the wrap along the r-coordinate. The default is kRepeat.
Definition: sampler.h:154
void SetMaxAnisotropy(float aniso)
Sets the maximum degree of anisotropy used when filtering textures.
Definition: sampler.h:113
void SetMinLod(float lod)
Sets the minimum level of detail parameter, which limits the selection of the highest resolution (low...
Definition: sampler.h:135
void SetWrapS(const WrapMode &mode)
Sets the wrap along the s-coordinate.
Definition: sampler.h:157
WrapMode
Texture filter modes.
Definition: sampler.h:77
base::ReferentPtr< Sampler >::Type SamplerPtr
Convenience typedef for shared pointer to a Sampler.
WrapMode GetWrapS() const
Gets the wrap along the s-coordinate. The default is kRepeat.
Definition: sampler.h:161
CompareMode GetCompareMode() const
Definition: sampler.h:102
void SetCompareMode(CompareMode mode)
Sets/returns the comparison mode to use for the texture using this sampler.
Definition: sampler.h:99
FilterMode GetMagFilter() const
Gets the magnification mode. The default is kNearest.
Definition: sampler.h:131
WrapMode GetWrapT() const
Gets the wrap along the t-coordinate. The default is kRepeat.
Definition: sampler.h:168
float GetMaxLod() const
Gets the maximum level of detail parameter. The default is 1000.
Definition: sampler.h:147
float GetMaxAnisotropy() const
Gets the maximum anisotropy parameter. The default is 1.
Definition: sampler.h:117
Changes
Changes that affect this resource.
Definition: sampler.h:32
CompareFunction GetCompareFunction() const
Definition: sampler.h:110
These are only usable with the minification filter.
Definition: sampler.h:70
void SetCompareFunction(CompareFunction func)
Sets/returns the comparison function to use when texture comparison is enabled, e.g., when this is used with a depth texture.
Definition: sampler.h:107
void SetMagFilter(const FilterMode &mode)
Sets the magnification mode.
Definition: sampler.h:127
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Definition: sharedptr.h:60
FilterMode
Texture filter modes.
Definition: sampler.h:66
void SetWrapR(const WrapMode &mode)
Sets the wrap along the r-coordinate (useful only for 3D textures).
Definition: sampler.h:150
ResourceHolder is an internal base class for objects that hold resources managed by an outside entity...
A Sampler object represents texture parameters that control how texture data is accessed in shaders...
Definition: sampler.h:29
CompareFunction
Texture comparison functions for depth textures.
Definition: sampler.h:48