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 |
const LColor & | get_border_color () const |
int | get_effective_anisotropic_degree () const |
FilterType | get_effective_magfilter () const |
FilterType | get_effective_minfilter () const |
PN_stdfloat | get_lod_bias () const |
FilterType | get_magfilter () const |
PN_stdfloat | get_max_lod () const |
PN_stdfloat | get_min_lod () const |
FilterType | get_minfilter () const |
WrapMode | get_wrap_u () const |
WrapMode | get_wrap_v () const |
WrapMode | get_wrap_w () const |
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 (std::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) |
void | set_border_color (const LColor &color) |
void | set_lod_bias (PN_stdfloat lod_bias) |
void | set_magfilter (FilterType filter) |
void | set_max_lod (PN_stdfloat max_lod) |
void | set_min_lod (PN_stdfloat min_lod) |
void | set_minfilter (FilterType filter) |
void | set_wrap_u (WrapMode wrap) |
void | set_wrap_v (WrapMode wrap) |
void | set_wrap_w (WrapMode wrap) |
bool | uses_mipmaps () const |
Returns true if the minfilter settings on this sampler indicate the use of mipmapping, false otherwise. More... | |
void | write (std::ostream &out, int indent) const |
void | write_datagram (Datagram &destination) const |
Encodes the sampler state into a datagram. More... | |
Static Public Member Functions | |
static std::string | format_filter_type (FilterType ft) |
Returns the indicated FilterType converted to a string word. More... | |
static std::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 std::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 std::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... | |
Public Attributes | |
get_anisotropic_degree | |
Returns the degree of anisotropic filtering that should be applied to the texture. More... | |
get_border_color | |
Returns the solid color of the texture's border. More... | |
get_effective_anisotropic_degree | |
Returns the degree of anisotropic filtering that should be applied to the texture. More... | |
get_effective_magfilter | |
Returns the filter mode of the texture for magnification, with special treatment for FT_default. More... | |
get_effective_minfilter | |
Returns the filter mode of the texture for minification, with special treatment for FT_default. More... | |
get_lod_bias | |
Returns the bias that will be added to the texture level of detail when sampling this texture. More... | |
get_magfilter | |
Returns the filter mode of the texture for magnification. More... | |
get_max_lod | |
Returns the maximum level of detail that will be observed when sampling this texture. More... | |
get_min_lod | |
Returns the minimum level of detail that will be observed when sampling this texture. More... | |
get_minfilter | |
Returns the filter mode of the texture for minification. More... | |
get_wrap_u | |
Returns the wrap mode of the texture in the U direction. More... | |
get_wrap_v | |
Returns the wrap mode of the texture in the V direction. More... | |
get_wrap_w | |
Returns the wrap mode of the texture in the W direction. More... | |
set_anisotropic_degree | |
Specifies the level of anisotropic filtering to apply to the SamplerState. More... | |
set_border_color | |
Specifies the solid color of the SamplerState's border. More... | |
set_lod_bias | |
Sets the value that will be added to the level of detail when sampling the texture. More... | |
set_magfilter | |
Sets the filtering method that should be used when viewing the SamplerState up close. More... | |
set_max_lod | |
Sets the maximum level of detail that will be used when sampling this texture. More... | |
set_min_lod | |
Sets the minimum level of detail that will be used when sampling this texture. More... | |
set_minfilter | |
Sets the filtering method that should be used when viewing the SamplerState from a distance. More... | |
set_wrap_u | |
This setting determines what happens when the SamplerState is sampled with a U value outside the range 0.0-1.0. More... | |
set_wrap_v | |
This setting determines what happens when the SamplerState is sampled with a V value outside the range 0.0-1.0. More... | |
set_wrap_w | |
The W wrap direction is only used for 3-d SamplerStates. 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 36 of file samplerState.h.
|
inline |
Creates a new SamplerState initialized to the default values.
Definition at line 18 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 249 of file samplerState.cxx.
|
static |
Returns the indicated FilterType converted to a string word.
Definition at line 88 of file samplerState.cxx.
|
static |
Returns the indicated WrapMode converted to a string word.
Definition at line 150 of file samplerState.cxx.
|
inlinestatic |
Returns a reference to the global default immutable SamplerState object.
Definition at line 36 of file samplerState.I.
|
inlinestatic |
Returns true if the indicated filter type requires the use of mipmaps, or false if it does not.
Definition at line 257 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 211 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 202 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 237 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 339 of file samplerState.cxx.
References BamReader::get_file_minor_ver(), DatagramIterator::get_int16(), DatagramIterator::get_stdfloat(), and DatagramIterator::get_uint8().
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 221 of file samplerState.cxx.
References PreparedGraphicsObjects::release_sampler().
|
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 122 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 175 of file samplerState.cxx.
|
inline |
Returns true if the minfilter settings on this sampler indicate the use of mipmapping, false otherwise.
Definition at line 248 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 321 of file samplerState.cxx.
References Datagram::add_int16(), Datagram::add_stdfloat(), and Datagram::add_uint8().
Referenced by ParamTextureSampler::write_datagram().
|
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 119 of file samplerState.h.
|
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 121 of file samplerState.h.
|
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 120 of file samplerState.h.
SamplerState::FilterType SamplerState::get_effective_magfilter |
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 118 of file samplerState.h.
SamplerState::FilterType SamplerState::get_effective_minfilter |
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 117 of file samplerState.h.
Referenced by uses_mipmaps().
|
inline |
Returns the bias that will be added to the texture level of detail when sampling this texture.
Definition at line 124 of file samplerState.h.
|
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 116 of file samplerState.h.
|
inline |
Returns the maximum level of detail that will be observed when sampling this texture.
Definition at line 123 of file samplerState.h.
|
inline |
Returns the minimum level of detail that will be observed when sampling this texture.
Definition at line 122 of file samplerState.h.
|
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 115 of file samplerState.h.
|
inline |
Returns the wrap mode of the texture in the U direction.
Definition at line 112 of file samplerState.h.
|
inline |
Returns the wrap mode of the texture in the V direction.
Definition at line 113 of file samplerState.h.
|
inline |
Returns the wrap mode of the texture in the W direction.
This is the depth direction of 3-d textures.
Definition at line 114 of file samplerState.h.
|
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 119 of file samplerState.h.
|
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 121 of file samplerState.h.
|
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 124 of file samplerState.h.
|
inline |
Sets the filtering method that should be used when viewing the SamplerState up close.
Definition at line 116 of file samplerState.h.
|
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 123 of file samplerState.h.
|
inline |
Sets the minimum level of detail that will be used when sampling this texture.
This may be a negative value.
Definition at line 122 of file samplerState.h.
|
inline |
Sets the filtering method that should be used when viewing the SamplerState from a distance.
Definition at line 115 of file samplerState.h.
|
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 112 of file samplerState.h.
|
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 113 of file samplerState.h.
|
inline |
The W wrap direction is only used for 3-d SamplerStates.
Definition at line 114 of file samplerState.h.