Panda3D
Loading...
Searching...
No Matches
samplerState.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file samplerState.I
10 * @author rdb
11 * @date 2014-12-09
12 */
13
14/**
15 * Creates a new SamplerState initialized to the default values.
16 */
19 _border_color(0, 0, 0, 1),
20 _wrap_u(WM_repeat),
21 _wrap_v(WM_repeat),
22 _wrap_w(WM_repeat),
23 _minfilter(FT_default),
24 _magfilter(FT_default),
25 _min_lod(-1000),
26 _max_lod(1000),
27 _lod_bias(0),
28 _anisotropic_degree(0)
29{
30}
31
32/**
33 * Returns a reference to the global default immutable SamplerState object.
34 */
37 return _default;
38}
39
40/**
41 * This setting determines what happens when the SamplerState is sampled with
42 * a U value outside the range 0.0-1.0. The default is WM_repeat, which
43 * indicates that the SamplerState should repeat indefinitely.
44 */
45INLINE void SamplerState::
46set_wrap_u(SamplerState::WrapMode wrap) {
47 _wrap_u = wrap;
48}
49
50/**
51 * This setting determines what happens when the SamplerState is sampled with
52 * a V value outside the range 0.0-1.0. The default is WM_repeat, which
53 * indicates that the SamplerState should repeat indefinitely.
54 */
55INLINE void SamplerState::
56set_wrap_v(SamplerState::WrapMode wrap) {
57 _wrap_v = wrap;
58}
59
60/**
61 * The W wrap direction is only used for 3-d SamplerStates.
62 */
63INLINE void SamplerState::
64set_wrap_w(SamplerState::WrapMode wrap) {
65 _wrap_w = wrap;
66}
67
68/**
69 * Sets the filtering method that should be used when viewing the SamplerState
70 * from a distance.
71 */
72INLINE void SamplerState::
73set_minfilter(SamplerState::FilterType filter) {
74 _minfilter = filter;
75}
76
77/**
78 * Sets the filtering method that should be used when viewing the SamplerState
79 * up close.
80 */
81INLINE void SamplerState::
82set_magfilter(SamplerState::FilterType filter) {
83 _magfilter = filter;
84}
85
86/**
87 * Specifies the level of anisotropic filtering to apply to the SamplerState.
88 * Set this 0 to indicate the default value, which is specified in the
89 * SamplerState-anisotropic-degree config variable.
90 *
91 * To explicitly disable anisotropic filtering, set this value to 1. To
92 * explicitly enable anisotropic filtering, set it to a value higher than 1;
93 * larger numbers indicate greater degrees of filtering.
94 */
95INLINE void SamplerState::
96set_anisotropic_degree(int anisotropic_degree) {
97 _anisotropic_degree = anisotropic_degree;
98}
99
100/**
101 * Specifies the solid color of the SamplerState's border. Some OpenGL
102 * implementations use a border for tiling SamplerStates; in Panda, it is only
103 * used for specifying the clamp color.
104 */
105INLINE void SamplerState::
106set_border_color(const LColor &color) {
107 _border_color = color;
108}
109
110/**
111 * Sets the minimum level of detail that will be used when sampling this
112 * texture. This may be a negative value.
113 */
114INLINE void SamplerState::
115set_min_lod(PN_stdfloat min_lod) {
116 _min_lod = min_lod;
117}
118
119/**
120 * Sets the maximum level of detail that will be used when sampling this
121 * texture. This may exceed the number of mipmap levels that the texture has.
122 */
123INLINE void SamplerState::
124set_max_lod(PN_stdfloat max_lod) {
125 _max_lod = max_lod;
126}
127
128/**
129 * Sets the value that will be added to the level of detail when sampling the
130 * texture. This may be a negative value, although some graphics hardware may
131 * not support the use of negative LOD values.
132 */
133INLINE void SamplerState::
134set_lod_bias(PN_stdfloat lod_bias) {
135 _lod_bias = lod_bias;
136}
137
138/**
139 * Returns the wrap mode of the texture in the U direction.
140 */
141INLINE SamplerState::WrapMode SamplerState::
142get_wrap_u() const {
143 return _wrap_u;
144}
145
146/**
147 * Returns the wrap mode of the texture in the V direction.
148 */
149INLINE SamplerState::WrapMode SamplerState::
150get_wrap_v() const {
151 return _wrap_v;
152}
153
154/**
155 * Returns the wrap mode of the texture in the W direction. This is the depth
156 * direction of 3-d textures.
157 */
158INLINE SamplerState::WrapMode SamplerState::
159get_wrap_w() const {
160 return _wrap_w;
161}
162
163/**
164 * Returns the filter mode of the texture for minification. If this is one of
165 * the mipmap constants, then the texture requires mipmaps. This may return
166 * FT_default; see also get_effective_minfilter().
167 */
168INLINE SamplerState::FilterType SamplerState::
169get_minfilter() const {
170 return _minfilter;
171}
172
173/**
174 * Returns the filter mode of the texture for magnification. The mipmap
175 * constants are invalid here. This may return FT_default; see also
176 * get_effective_minfilter().
177 */
178INLINE SamplerState::FilterType SamplerState::
179get_magfilter() const {
180 return _magfilter;
181}
182
183/**
184 * Returns the degree of anisotropic filtering that should be applied to the
185 * texture. This value may return 0, indicating the default value; see also
186 * get_effective_anisotropic_degree.
187 */
188INLINE int SamplerState::
190 return _anisotropic_degree;
191}
192
193/**
194 * Returns the degree of anisotropic filtering that should be applied to the
195 * texture. This value will normally not return 0, unless there is an error
196 * in the config file.
197 */
198INLINE int SamplerState::
200 if (_anisotropic_degree != 0) {
201 return _anisotropic_degree;
202 }
203 return texture_anisotropic_degree;
204}
205
206/**
207 * Returns the solid color of the texture's border. Some OpenGL
208 * implementations use a border for tiling textures; in Panda, it is only used
209 * for specifying the clamp color.
210 */
211INLINE const LColor &SamplerState::
212get_border_color() const {
213 return _border_color;
214}
215
216/**
217 * Returns the minimum level of detail that will be observed when sampling
218 * this texture.
219 */
220INLINE PN_stdfloat SamplerState::
221get_min_lod() const {
222 return _min_lod;
223}
224
225/**
226 * Returns the maximum level of detail that will be observed when sampling
227 * this texture.
228 */
229INLINE PN_stdfloat SamplerState::
230get_max_lod() const {
231 return _max_lod;
232}
233
234/**
235 * Returns the bias that will be added to the texture level of detail when
236 * sampling this texture.
237 */
238INLINE PN_stdfloat SamplerState::
239get_lod_bias() const {
240 return _lod_bias;
241}
242
243/**
244 * Returns true if the minfilter settings on this sampler indicate the use of
245 * mipmapping, false otherwise.
246 */
247INLINE bool SamplerState::
248uses_mipmaps() const {
250}
251
252/**
253 * Returns true if the indicated filter type requires the use of mipmaps, or
254 * false if it does not.
255 */
256INLINE bool SamplerState::
257is_mipmap(FilterType filter_type) {
258 switch (filter_type) {
259 case SamplerState::FT_nearest_mipmap_nearest:
260 case SamplerState::FT_linear_mipmap_nearest:
261 case SamplerState::FT_nearest_mipmap_linear:
262 case SamplerState::FT_linear_mipmap_linear:
263 return true;
264
265 default:
266 return false;
267 }
268}
269
270/**
271 *
272 */
273INLINE bool SamplerState::
274operator == (const SamplerState &other) const {
275 return compare_to(other) == 0;
276}
277
278/**
279 *
280 */
281INLINE bool SamplerState::
282operator != (const SamplerState &other) const {
283 return compare_to(other) != 0;
284}
285
286/**
287 *
288 */
289INLINE bool SamplerState::
290operator < (const SamplerState &other) const {
291 return compare_to(other) < 0;
292}
Represents a set of settings that indicate how a texture is sampled.
get_max_lod
Returns the maximum level of detail that will be observed when sampling this texture.
static bool is_mipmap(FilterType type)
Returns true if the indicated filter type requires the use of mipmaps, or false if it does not.
set_wrap_v
This setting determines what happens when the SamplerState is sampled with a V value outside the rang...
set_max_lod
Sets the maximum level of detail that will be used when sampling this texture.
static const SamplerState & get_default()
Returns a reference to the global default immutable SamplerState object.
get_minfilter
Returns the filter mode of the texture for minification.
get_wrap_v
Returns the wrap mode of the texture in the V direction.
set_anisotropic_degree
Specifies the level of anisotropic filtering to apply to the SamplerState.
set_border_color
Specifies the solid color of the SamplerState's border.
get_anisotropic_degree
Returns the degree of anisotropic filtering that should be applied to the texture.
set_wrap_w
The W wrap direction is only used for 3-d SamplerStates.
get_magfilter
Returns the filter mode of the texture for magnification.
get_wrap_w
Returns the wrap mode of the texture in the W direction.
set_min_lod
Sets the minimum level of detail that will be used when sampling this texture.
set_minfilter
Sets the filtering method that should be used when viewing the SamplerState from a distance.
set_wrap_u
This setting determines what happens when the SamplerState is sampled with a U value outside the rang...
SamplerState()
Creates a new SamplerState initialized to the default values.
bool uses_mipmaps() const
Returns true if the minfilter settings on this sampler indicate the use of mipmapping,...
get_lod_bias
Returns the bias that will be added to the texture level of detail when sampling this texture.
set_magfilter
Sets the filtering method that should be used when viewing the SamplerState up close.
get_min_lod
Returns the minimum level of detail that will be observed when sampling this texture.
int compare_to(const SamplerState &other) const
Returns a number less than zero if this sampler sorts before the other one, greater than zero if it s...
get_effective_minfilter
Returns the filter mode of the texture for minification, with special treatment for FT_default.
get_effective_anisotropic_degree
Returns the degree of anisotropic filtering that should be applied to the texture.
get_wrap_u
Returns the wrap mode of the texture in the U direction.
set_lod_bias
Sets the value that will be added to the level of detail when sampling the texture.
get_border_color
Returns the solid color of the texture's border.