29 (
"texture-minfilter", SamplerState::FT_linear,
30 PRC_DESC(
"This specifies the default minfilter that is applied to a texture " 31 "in the absence of a specific minfilter setting. Normally this " 32 "is either 'linear' to disable mipmapping by default, or " 33 "'mipmap', to enable trilinear mipmapping by default. This " 34 "does not apply to depth textures. Note if this variable is " 35 "changed at runtime, you may need to reload textures explicitly " 36 "in order to change their visible properties."));
39 (
"texture-magfilter", SamplerState::FT_linear,
40 PRC_DESC(
"This specifies the default magfilter that is applied to a texture " 41 "in the absence of a specific magfilter setting. Normally this " 42 "is 'linear' (since mipmapping does not apply to magfilters). This " 43 "does not apply to depth textures. Note if this variable is " 44 "changed at runtime, you may need to reload textures explicitly " 45 "in order to change their visible properties."));
48 (
"texture-anisotropic-degree", 1,
49 PRC_DESC(
"This specifies the default anisotropic degree that is applied " 50 "to a texture in the absence of a particular anisotropic degree " 51 "setting (that is, a texture for which the anisotropic degree " 52 "is 0, meaning the default setting). It should be 1 to disable " 53 "anisotropic filtering, or a higher number to enable it. " 54 "Note if this variable is " 55 "changed at runtime, you may need to reload textures explicitly " 56 "in order to change their visible properties."));
63 SamplerState::FilterType SamplerState::
64 get_effective_minfilter()
const {
65 if (_minfilter != FT_default) {
68 return texture_minfilter;
76 SamplerState::FilterType SamplerState::
77 get_effective_magfilter()
const {
78 if (_magfilter != FT_default) {
81 return texture_magfilter;
95 case FT_nearest_mipmap_nearest:
96 return "nearest_mipmap_nearest";
97 case FT_linear_mipmap_nearest:
98 return "linear_mipmap_nearest";
99 case FT_nearest_mipmap_linear:
100 return "nearest_mipmap_linear";
101 case FT_linear_mipmap_linear:
102 return "linear_mipmap_linear";
113 return "**invalid**";
123 if (cmp_nocase_uh(
string,
"nearest") == 0) {
125 }
else if (cmp_nocase_uh(
string,
"linear") == 0) {
127 }
else if (cmp_nocase_uh(
string,
"nearest_mipmap_nearest") == 0) {
128 return FT_nearest_mipmap_nearest;
129 }
else if (cmp_nocase_uh(
string,
"linear_mipmap_nearest") == 0) {
130 return FT_linear_mipmap_nearest;
131 }
else if (cmp_nocase_uh(
string,
"nearest_mipmap_linear") == 0) {
132 return FT_nearest_mipmap_linear;
133 }
else if (cmp_nocase_uh(
string,
"linear_mipmap_linear") == 0) {
134 return FT_linear_mipmap_linear;
135 }
else if (cmp_nocase_uh(
string,
"mipmap") == 0) {
136 return FT_linear_mipmap_linear;
137 }
else if (cmp_nocase_uh(
string,
"shadow") == 0) {
139 }
else if (cmp_nocase_uh(
string,
"default") == 0) {
159 return "mirror_once";
160 case WM_border_color:
161 return "border_color";
167 return "**invalid**";
176 if (cmp_nocase_uh(
string,
"repeat") == 0 ||
177 cmp_nocase_uh(
string,
"wrap") == 0) {
179 }
else if (cmp_nocase_uh(
string,
"clamp") == 0) {
181 }
else if (cmp_nocase_uh(
string,
"mirror") == 0 ||
182 cmp_nocase_uh(
string,
"mirrored_repeat") == 0) {
184 }
else if (cmp_nocase_uh(
string,
"mirror_once") == 0) {
185 return WM_mirror_once;
186 }
else if (cmp_nocase_uh(
string,
"border_color") == 0 ||
187 cmp_nocase_uh(
string,
"border") == 0) {
188 return WM_border_color;
250 if (_wrap_u != other._wrap_u) {
251 return (_wrap_u < other._wrap_u) ? -1 : 1;
253 if (_wrap_v != other._wrap_v) {
254 return (_wrap_v < other._wrap_v) ? -1 : 1;
256 if (_wrap_w != other._wrap_w) {
257 return (_wrap_w < other._wrap_w) ? -1 : 1;
259 if (_minfilter != other._minfilter) {
260 return (_minfilter < other._minfilter) ? -1 : 1;
262 if (_magfilter != other._magfilter) {
263 return (_magfilter < other._magfilter) ? -1 : 1;
265 if (_anisotropic_degree != other._anisotropic_degree) {
266 return (_anisotropic_degree < other._anisotropic_degree) ? -1 : 1;
268 if (_border_color != other._border_color) {
269 return (_border_color < other._border_color) ? -1 : 1;
271 if (_min_lod != other._min_lod) {
272 return (_min_lod < other._min_lod) ? -1 : 1;
274 if (_max_lod != other._max_lod) {
275 return (_max_lod < other._max_lod) ? -1 : 1;
277 if (_lod_bias != other._lod_bias) {
278 return (_lod_bias < other._lod_bias) ? -1 : 1;
288 output(std::ostream &out)
const {
291 <<
" wrap(u=" << _wrap_u <<
", v=" << _wrap_v <<
", w=" << _wrap_w
292 <<
", border=" << _border_color <<
")" 293 <<
" filter(min=" << _minfilter <<
", mag=" << _magfilter
294 <<
", aniso=" << _anisotropic_degree <<
")" 295 <<
" lod(min=" << _min_lod <<
", max=" << _max_lod
296 <<
", bias=" << _lod_bias <<
")";
303 write(std::ostream &out,
int indent_level)
const {
304 indent(out, indent_level) <<
"SamplerState\n";
305 indent(out, indent_level) <<
" wrap_u = " << _wrap_u <<
"\n";
306 indent(out, indent_level) <<
" wrap_v = " << _wrap_v <<
"\n";
307 indent(out, indent_level) <<
" wrap_w = " << _wrap_w <<
"\n";
308 indent(out, indent_level) <<
" minfilter = " << _minfilter <<
"\n";
309 indent(out, indent_level) <<
" magfilter = " << _magfilter <<
"\n";
310 indent(out, indent_level) <<
" anisotropic_degree = " << _anisotropic_degree <<
"\n";
311 indent(out, indent_level) <<
" border_color = " << _border_color <<
"\n";
312 indent(out, indent_level) <<
" min_lod = " << _min_lod <<
"\n";
313 indent(out, indent_level) <<
" max_lod = " << _max_lod <<
"\n";
314 indent(out, indent_level) <<
" lod_bias = " << _lod_bias <<
"\n";
328 _border_color.write_datagram(me);
343 _minfilter = (FilterType)scan.
get_uint8();
344 _magfilter = (FilterType)scan.
get_uint8();
346 _border_color.read_datagram(scan);
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.
void add_int16(int16_t value)
Adds a signed 16-bit integer to the datagram.
static WrapMode string_wrap_mode(const std::string &str)
Returns the WrapMode value associated with the given string representation, or WM_invalid if the stri...
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static std::string format_wrap_mode(WrapMode wm)
Returns the indicated WrapMode converted to a string word.
void read_datagram(DatagramIterator &source, BamReader *manager)
Reads the sampler state from the datagram that has been previously written using write_datagram.
static std::string format_filter_type(FilterType ft)
Returns the indicated FilterType converted to a string word.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void release(PreparedGraphicsObjects *prepared_objects) const
Frees the texture context only on the indicated object, if it exists there.
void enqueue_sampler(const SamplerState &sampler)
Indicates that a sampler would like to be put on the list to be prepared when the GSG is next ready t...
bool is_sampler_prepared(const SamplerState &sampler) const
Returns true if the sampler has been prepared on this GSG, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A table of objects that are saved within the graphics context for reference by handle later.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
void write_datagram(Datagram &destination) const
Encodes the sampler state into a datagram.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
static FilterType string_filter_type(const std::string &str)
Returns the FilterType value associated with the given string representation, or FT_invalid if the st...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
SamplerContext * prepare_sampler_now(const SamplerState &sampler, GraphicsStateGuardianBase *gsg)
Immediately creates a new SamplerContext for the indicated sampler and returns it.
This class specializes ConfigVariable as an enumerated type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_sampler_queued(const SamplerState &sampler) const
Returns true if the sampler has been queued on this GSG, false otherwise.
Represents a set of settings that indicate how a texture is sampled.
This is a special class object that holds a handle to the sampler state object given by the graphics ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
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...
This is a convenience class to specialize ConfigVariable as an integer type.
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
int16_t get_int16()
Extracts a signed 16-bit integer.
A class to retrieve the individual data elements previously stored in a Datagram.
void release_sampler(SamplerContext *sc)
Indicates that a sampler context, created by a previous call to prepare_sampler(),...
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void prepare(PreparedGraphicsObjects *prepared_objects) const
Indicates that the sampler should be enqueued to be prepared in the indicated prepared_objects at the...
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the sampler has already been prepared or enqueued for preparation on the indicated GS...