Represents a set of settings that indicate how a texture is sampled. More...
#include "samplerState.h"
Public Member Functions | |
SamplerState () | |
Creates a new SamplerState initialized to the default values. More... | |
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 sorts after, or zero if they are equivalent. More... | |
int | get_anisotropic_degree () const |
Returns the degree of anisotropic filtering that should be applied to the texture. More... | |
const LColor & | get_border_color () const |
Returns the solid color of the texture's border. More... | |
int | get_effective_anisotropic_degree () const |
Returns the degree of anisotropic filtering that should be applied to the texture. More... | |
FilterType | get_effective_magfilter () const |
Returns the filter mode of the texture for magnification, with special treatment for FT_default. More... | |
FilterType | get_effective_minfilter () const |
Returns the filter mode of the texture for minification, with special treatment for FT_default. More... | |
PN_stdfloat | get_lod_bias () const |
Returns the bias that will be added to the texture level of detail when sampling this texture. More... | |
FilterType | get_magfilter () const |
Returns the filter mode of the texture for magnification. More... | |
PN_stdfloat | get_max_lod () const |
Returns the maximum level of detail that will be observed when sampling this texture. More... | |
PN_stdfloat | get_min_lod () const |
Returns the minimum level of detail that will be observed when sampling this texture. More... | |
FilterType | get_minfilter () const |
Returns the filter mode of the texture for minification. More... | |
WrapMode | get_wrap_u () const |
Returns the wrap mode of the texture in the U direction. More... | |
WrapMode | get_wrap_v () const |
Returns the wrap mode of the texture in the V direction. More... | |
WrapMode | get_wrap_w () const |
Returns the wrap mode of the texture in the W direction. More... | |
bool | is_prepared (PreparedGraphicsObjects *prepared_objects) const |
Returns true if the sampler has already been prepared or enqueued for preparation on the indicated GSG, false otherwise. More... | |
bool | operator!= (const SamplerState &other) const |
bool | operator< (const SamplerState &other) const |
bool | operator== (const SamplerState &other) const |
void | output (ostream &out) const |
void | prepare (PreparedGraphicsObjects *prepared_objects) const |
Indicates that the sampler should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame. More... | |
SamplerContext * | prepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) const |
Creates a context for the sampler on the particular GSG, if it does not already exist. More... | |
void | read_datagram (DatagramIterator &source, BamReader *manager) |
Reads the sampler state from the datagram that has been previously written using write_datagram. More... | |
void | release (PreparedGraphicsObjects *prepared_objects) const |
Frees the texture context only on the indicated object, if it exists there. More... | |
void | set_anisotropic_degree (int anisotropic_degree) |
Specifies the level of anisotropic filtering to apply to the SamplerState. More... | |
void | set_border_color (const LColor &color) |
Specifies the solid color of the SamplerState's border. More... | |
void | set_lod_bias (PN_stdfloat lod_bias) |
Sets the value that will be added to the level of detail when sampling the texture. More... | |
void | set_magfilter (FilterType filter) |
Sets the filtering method that should be used when viewing the SamplerState up close. More... | |
void | set_max_lod (PN_stdfloat max_lod) |
Sets the maximum level of detail that will be used when sampling this texture. More... | |
void | set_min_lod (PN_stdfloat min_lod) |
Sets the minimum level of detail that will be used when sampling this texture. More... | |
void | set_minfilter (FilterType filter) |
Sets the filtering method that should be used when viewing the SamplerState from a distance. More... | |
void | set_wrap_u (WrapMode wrap) |
This setting determines what happens when the SamplerState is sampled with a U value outside the range 0.0-1.0. More... | |
void | set_wrap_v (WrapMode wrap) |
This setting determines what happens when the SamplerState is sampled with a V value outside the range 0.0-1.0. More... | |
void | set_wrap_w (WrapMode wrap) |
The W wrap direction is only used for 3-d SamplerStates. More... | |
bool | uses_mipmaps () const |
Returns true if the minfilter settings on this sampler indicate the use of mipmapping, false otherwise. More... | |
void | write (ostream &out, int indent) const |
void | write_datagram (Datagram &destination) const |
Encodes the sampler state into a datagram. More... | |
Static Public Member Functions | |
static string | format_filter_type (FilterType ft) |
Returns the indicated FilterType converted to a string word. More... | |
static string | format_wrap_mode (WrapMode wm) |
Returns the indicated WrapMode converted to a string word. More... | |
static TypeHandle | get_class_type () |
static const SamplerState & | get_default () |
Returns a reference to the global default immutable SamplerState object. More... | |
static void | init_type () |
static bool | is_mipmap (FilterType type) |
Returns true if the indicated filter type requires the use of mipmaps, or false if it does not. More... | |
static FilterType | string_filter_type (const string &str) |
Returns the FilterType value associated with the given string representation, or FT_invalid if the string does not match any known FilterType value. More... | |
static WrapMode | string_wrap_mode (const string &str) |
Returns the WrapMode value associated with the given string representation, or WM_invalid if the string does not match any known WrapMode value. More... | |
Represents a set of settings that indicate how a texture is sampled.
This can be used to sample the same texture using different settings in different places.
Definition at line 39 of file samplerState.h.
|
inline |
Creates a new SamplerState initialized to the default values.
Definition at line 23 of file samplerState.I.
int SamplerState::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 sorts after, or zero if they are equivalent.
The sorting order is arbitrary and largely meaningless, except to differentiate different sampler states.
Definition at line 282 of file samplerState.cxx.
|
static |
Returns the indicated FilterType converted to a string word.
Definition at line 96 of file samplerState.cxx.
|
static |
Returns the indicated WrapMode converted to a string word.
Definition at line 163 of file samplerState.cxx.
|
inline |
Returns the degree of anisotropic filtering that should be applied to the texture.
This value may return 0, indicating the default value; see also get_effective_anisotropic_degree.
Definition at line 244 of file samplerState.I.
|
inline |
Returns the solid color of the texture's border.
Some OpenGL implementations use a border for tiling textures; in Panda, it is only used for specifying the clamp color.
Definition at line 273 of file samplerState.I.
Referenced by DXGraphicsStateGuardian9::apply_texture().
|
inlinestatic |
Returns a reference to the global default immutable SamplerState object.
Definition at line 44 of file samplerState.I.
Referenced by TextureAttrib::get_on_sampler(), ShaderAttrib::get_shader_input_sampler(), and NodePath::get_texture_sampler().
|
inline |
Returns the degree of anisotropic filtering that should be applied to the texture.
This value will normally not return 0, unless there is an error in the config file.
Definition at line 257 of file samplerState.I.
Referenced by DXGraphicsStateGuardian9::apply_texture().
SamplerState::FilterType SamplerState::get_effective_magfilter | ( | ) | const |
Returns the filter mode of the texture for magnification, with special treatment for FT_default.
This will normally not return FT_default, unless there is an error in the config file.
Definition at line 82 of file samplerState.cxx.
Referenced by DXGraphicsStateGuardian9::apply_texture().
SamplerState::FilterType SamplerState::get_effective_minfilter | ( | ) | const |
Returns the filter mode of the texture for minification, with special treatment for FT_default.
This will normally not return FT_default, unless there is an error in the config file.
Definition at line 66 of file samplerState.cxx.
Referenced by DXGraphicsStateGuardian9::apply_texture(), and uses_mipmaps().
|
inline |
Returns the bias that will be added to the texture level of detail when sampling this texture.
Definition at line 306 of file samplerState.I.
Referenced by DXGraphicsStateGuardian9::apply_texture().
|
inline |
Returns the filter mode of the texture for magnification.
The mipmap constants are invalid here. This may return FT_default; see also get_effective_minfilter().
Definition at line 231 of file samplerState.I.
|
inline |
Returns the maximum level of detail that will be observed when sampling this texture.
Definition at line 295 of file samplerState.I.
|
inline |
Returns the minimum level of detail that will be observed when sampling this texture.
Definition at line 284 of file samplerState.I.
|
inline |
Returns the filter mode of the texture for minification.
If this is one of the mipmap constants, then the texture requires mipmaps. This may return FT_default; see also get_effective_minfilter().
Definition at line 218 of file samplerState.I.
|
inline |
Returns the wrap mode of the texture in the U direction.
Definition at line 181 of file samplerState.I.
Referenced by DXGraphicsStateGuardian9::apply_texture().
|
inline |
Returns the wrap mode of the texture in the V direction.
Definition at line 192 of file samplerState.I.
Referenced by DXGraphicsStateGuardian9::apply_texture().
|
inline |
Returns the wrap mode of the texture in the W direction.
This is the depth direction of 3-d textures.
Definition at line 204 of file samplerState.I.
Referenced by DXGraphicsStateGuardian9::apply_texture().
|
inlinestatic |
Returns true if the indicated filter type requires the use of mipmaps, or false if it does not.
Definition at line 329 of file samplerState.I.
Referenced by uses_mipmaps(), and Texture::uses_mipmaps().
bool SamplerState::is_prepared | ( | PreparedGraphicsObjects * | prepared_objects | ) | const |
Returns true if the sampler has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.
Definition at line 233 of file samplerState.cxx.
References PreparedGraphicsObjects::is_sampler_prepared(), and PreparedGraphicsObjects::is_sampler_queued().
void SamplerState::prepare | ( | PreparedGraphicsObjects * | prepared_objects | ) | const |
Indicates that the sampler should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.
Use this function instead of prepare_now() to preload samplers from a user interface standpoint.
Definition at line 221 of file samplerState.cxx.
References PreparedGraphicsObjects::enqueue_sampler().
SamplerContext * SamplerState::prepare_now | ( | PreparedGraphicsObjects * | prepared_objects, |
GraphicsStateGuardianBase * | gsg | ||
) | const |
Creates a context for the sampler on the particular GSG, if it does not already exist.
Returns the new (or old) SamplerContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new textures. If this is not necessarily the case, you should use prepare() instead.
Normally, this is not called directly except by the GraphicsStateGuardian; a sampler does not need to be explicitly prepared by the user before it may be rendered.
Definition at line 267 of file samplerState.cxx.
References PreparedGraphicsObjects::prepare_sampler_now().
Referenced by PreparedGraphicsObjects::begin_frame().
void SamplerState::read_datagram | ( | DatagramIterator & | source, |
BamReader * | manager | ||
) |
Reads the sampler state from the datagram that has been previously written using write_datagram.
Definition at line 380 of file samplerState.cxx.
References BamReader::get_file_minor_ver(), DatagramIterator::get_int16(), DatagramIterator::get_stdfloat(), DatagramIterator::get_uint8(), and LVecBase4f::read_datagram().
void SamplerState::release | ( | PreparedGraphicsObjects * | prepared_objects | ) | const |
Frees the texture context only on the indicated object, if it exists there.
Returns true if it was released, false if it had not been prepared.
Definition at line 246 of file samplerState.cxx.
References PreparedGraphicsObjects::release_sampler().
|
inline |
Specifies the level of anisotropic filtering to apply to the SamplerState.
Set this 0 to indicate the default value, which is specified in the SamplerState-anisotropic-degree config variable.
To explicitly disable anisotropic filtering, set this value to 1. To explicitly enable anisotropic filtering, set it to a value higher than 1; larger numbers indicate greater degrees of filtering.
Definition at line 120 of file samplerState.I.
|
inline |
Specifies the solid color of the SamplerState's border.
Some OpenGL implementations use a border for tiling SamplerStates; in Panda, it is only used for specifying the clamp color.
Definition at line 133 of file samplerState.I.
|
inline |
Sets the value that will be added to the level of detail when sampling the texture.
This may be a negative value, although some graphics hardware may not support the use of negative LOD values.
Definition at line 170 of file samplerState.I.
|
inline |
Sets the filtering method that should be used when viewing the SamplerState up close.
Definition at line 102 of file samplerState.I.
|
inline |
Sets the maximum level of detail that will be used when sampling this texture.
This may exceed the number of mipmap levels that the texture has.
Definition at line 157 of file samplerState.I.
|
inline |
Sets the minimum level of detail that will be used when sampling this texture.
This may be a negative value.
Definition at line 145 of file samplerState.I.
|
inline |
Sets the filtering method that should be used when viewing the SamplerState from a distance.
Definition at line 91 of file samplerState.I.
|
inline |
This setting determines what happens when the SamplerState is sampled with a U value outside the range 0.0-1.0.
The default is WM_repeat, which indicates that the SamplerState should repeat indefinitely.
Definition at line 57 of file samplerState.I.
|
inline |
This setting determines what happens when the SamplerState is sampled with a V value outside the range 0.0-1.0.
The default is WM_repeat, which indicates that the SamplerState should repeat indefinitely.
Definition at line 70 of file samplerState.I.
|
inline |
The W wrap direction is only used for 3-d SamplerStates.
Definition at line 80 of file samplerState.I.
|
static |
Returns the FilterType value associated with the given string representation, or FT_invalid if the string does not match any known FilterType value.
Definition at line 132 of file samplerState.cxx.
|
static |
Returns the WrapMode value associated with the given string representation, or WM_invalid if the string does not match any known WrapMode value.
Definition at line 191 of file samplerState.cxx.
|
inline |
Returns true if the minfilter settings on this sampler indicate the use of mipmapping, false otherwise.
Definition at line 318 of file samplerState.I.
References get_effective_minfilter(), and is_mipmap().
void SamplerState::write_datagram | ( | Datagram & | destination | ) | const |
Encodes the sampler state into a datagram.
Definition at line 360 of file samplerState.cxx.
References Datagram::add_int16(), Datagram::add_stdfloat(), Datagram::add_uint8(), and LVecBase4f::write_datagram().
Referenced by ParamTextureSampler::write_datagram().