27 PT(
Texture) tex = make_copy_impl();
28 CDWriter cdata_tex(tex->_cycler,
true);
29 cdata_tex->_render_to_texture =
false;
30 cdata_tex->inc_properties_modified();
31 cdata_tex->inc_image_modified();
32 cdata_tex->inc_simple_image_modified();
42 CDWriter cdata(_cycler,
true);
53setup_texture(Texture::TextureType texture_type,
int x_size,
int y_size,
54 int z_size, Texture::ComponentType component_type,
55 Texture::Format format) {
57 do_setup_texture(cdata, texture_type, x_size, y_size, z_size,
58 component_type, format);
79 setup_texture(TT_1d_texture, x_size, 1, 1, component_type, format);
101 setup_texture(TT_2d_texture, x_size, y_size, 1, component_type, format);
122 ComponentType component_type, Format format) {
123 setup_texture(TT_3d_texture, x_size, y_size, z_size, component_type, format);
146 ComponentType component_type, Format format) {
147 setup_texture(TT_2d_texture_array, x_size, y_size, z_size, component_type, format);
170setup_cube_map(
int size, ComponentType component_type, Format format) {
171 setup_texture(TT_cube_map, size, size, 6, component_type, format);
200 setup_texture(TT_cube_map_array, size, size, num_cube_maps * 6, component_type, format);
213 GeomEnums::UsageHint usage) {
214 setup_texture(TT_buffer_texture, size, 1, 1, component_type, format);
216 cdata->_usage_hint = usage;
233 do_clear_ram_image(cdata);
234 do_clear_simple_ram_image(cdata);
235 cdata->inc_image_modified();
236 cdata->inc_simple_image_modified();
244 CDReader cdata(_cycler);
245 return cdata->_has_clear_color;
253 CDReader cdata(_cycler);
254 return cdata->_clear_color;
268 CDWriter cdata(_cycler,
true);
269 cdata->_clear_color = color;
270 cdata->_has_clear_color =
true;
279 CDWriter cdata(_cycler,
true);
280 cdata->_has_clear_color =
true;
290 vector_uchar data(16);
291 data.resize(do_get_clear_data(cdata, &data[0]));
303 return do_write(cdata, fullpath, 0, 0,
false,
false);
349 bool write_pages,
bool write_mipmaps) {
351 return do_write(cdata, fullpath, z, n, write_pages, write_mipmaps);
361 cdata->inc_properties_modified();
362 cdata->inc_image_modified();
363 if (do_load_one(cdata, pnmimage, get_name(), 0, 0, options)) {
364 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
365 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
377 cdata->inc_properties_modified();
378 cdata->inc_image_modified();
379 if (do_load_one(cdata, pnmimage, get_name(), z, n, options)) {
392 cdata->inc_properties_modified();
393 cdata->inc_image_modified();
394 if (do_load_one(cdata, pfm, get_name(), 0, 0, options)) {
395 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
396 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
408 cdata->inc_properties_modified();
409 cdata->inc_image_modified();
410 if (do_load_one(cdata, pfm, get_name(), z, n, options)) {
426 return do_load_sub_image(cdata, image, x, y, z, n);
435 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, 0, 0);
444 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, z, n);
453 return ((
Texture *)
this)->do_store_one(cdata, pfm, 0, 0);
462 return ((
Texture *)
this)->do_store_one(cdata, pfm, z, n);
475 return do_reload(cdata);
484 CDReader cdata(_cycler);
485 return !cdata->_filename.empty();
494 CDReader cdata(_cycler);
495 return cdata->_filename;
504 CDReader cdata(_cycler);
505 return !cdata->_alpha_filename.empty();
515 CDReader cdata(_cycler);
516 return cdata->_alpha_filename;
525 CDReader cdata(_cycler);
526 return !cdata->_fullpath.empty();
535 CDReader cdata(_cycler);
536 return cdata->_fullpath;
545 CDReader cdata(_cycler);
546 return !cdata->_alpha_fullpath.empty();
556 CDReader cdata(_cycler);
557 return cdata->_alpha_fullpath;
566 CDReader cdata(_cycler);
567 return cdata->_x_size;
576 CDReader cdata(_cycler);
577 return cdata->_y_size;
586 CDReader cdata(_cycler);
587 return cdata->_z_size;
601 CDReader cdata(_cycler);
602 return cdata->_num_views;
623 return cdata->_pad_x_size;
632 return cdata->_pad_y_size;
641 return cdata->_pad_z_size;
658 if (cdata->_pad_x_size == 0 || cdata->_pad_y_size == 0 ||
659 cdata->_x_size == 0 || cdata->_y_size == 0) {
660 LVecBase2(1.0f, 1.0f);
662 return LVecBase2((PN_stdfloat)(cdata->_x_size - cdata->_pad_x_size) / (PN_stdfloat)cdata->_x_size,
663 (PN_stdfloat)(cdata->_y_size - cdata->_pad_y_size) / (PN_stdfloat)cdata->_y_size);
680 do_set_pad_size(cdata, x, y, z);
690 CDReader cdata(_cycler);
691 return cdata->_orig_file_x_size;
701 CDReader cdata(_cycler);
702 return cdata->_orig_file_y_size;
714 CDReader cdata(_cycler);
715 return cdata->_z_size;
725 CDReader cdata(_cycler);
726 return cdata->_num_components;
735 CDReader cdata(_cycler);
736 return cdata->_component_width;
744 CDReader cdata(_cycler);
745 return cdata->_texture_type;
754 CDReader cdata(_cycler);
755 return cdata->_format;
763 CDReader cdata(_cycler);
764 return cdata->_component_type;
773 CDReader cdata(_cycler);
774 return cdata->_usage_hint;
787 CDWriter cdata(_cycler,
true);
788 do_set_wrap_u(cdata, wrap);
801 CDWriter cdata(_cycler,
true);
802 do_set_wrap_v(cdata, wrap);
813 CDWriter cdata(_cycler,
true);
814 do_set_wrap_w(cdata, wrap);
826 CDWriter cdata(_cycler,
true);
827 do_set_minfilter(cdata, filter);
839 CDWriter cdata(_cycler,
true);
840 do_set_magfilter(cdata, filter);
857 CDWriter cdata(_cycler,
true);
858 do_set_anisotropic_degree(cdata, anisotropic_degree);
871 CDWriter cdata(_cycler,
true);
872 do_set_border_color(cdata, color);
891 CDWriter cdata(_cycler,
true);
892 do_set_compression(cdata, compression);
910 CDWriter cdata(_cycler,
false);
911 cdata->_render_to_texture = render_to_texture;
921 CDReader cdata(_cycler);
922 return cdata->_default_sampler;
938 CDWriter cdata(_cycler,
true);
939 cdata->_default_sampler = sampler;
940 cdata->inc_properties_modified();
951 CDReader cdata(_cycler);
952 return cdata->_default_sampler.get_wrap_u();
963 CDReader cdata(_cycler);
964 return cdata->_default_sampler.get_wrap_v();
976 CDReader cdata(_cycler);
977 return cdata->_default_sampler.get_wrap_w();
990 CDReader cdata(_cycler);
991 return cdata->_default_sampler.get_minfilter();
1002INLINE SamplerState::FilterType
Texture::
1004 CDReader cdata(_cycler);
1005 return cdata->_default_sampler.get_magfilter();
1018 CDReader cdata(_cycler);
1019 return cdata->_default_sampler.get_effective_minfilter();
1032 CDReader cdata(_cycler);
1033 return cdata->_default_sampler.get_effective_magfilter();
1046 CDReader cdata(_cycler);
1047 return cdata->_default_sampler.get_anisotropic_degree();
1060 CDReader cdata(_cycler);
1061 return cdata->_default_sampler.get_effective_anisotropic_degree();
1074 CDReader cdata(_cycler);
1075 return cdata->_default_sampler.get_border_color();
1087INLINE Texture::CompressionMode
Texture::
1089 CDReader cdata(_cycler);
1090 return cdata->_compression;
1105 return do_has_compression(cdata);
1119 CDReader cdata(_cycler);
1120 return cdata->_render_to_texture;
1140 CDWriter cdata(_cycler,
true);
1141 do_set_quality_level(cdata, quality_level);
1150 CDReader cdata(_cycler);
1151 return cdata->_quality_level;
1161 CDReader cdata(_cycler);
1162 if (cdata->_quality_level == QL_default) {
1163 return texture_quality_level;
1165 return cdata->_quality_level;
1177 CDReader cdata(_cycler);
1178 return do_get_expected_num_mipmap_levels(cdata);
1188 return do_get_expected_mipmap_x_size(cdata, n);
1198 return do_get_expected_mipmap_y_size(cdata, n);
1208 return do_get_expected_mipmap_z_size(cdata, n);
1220 return do_get_expected_mipmap_num_pages(cdata, n);
1245 return do_has_ram_image(cdata);
1255 return do_has_uncompressed_ram_image(cdata);
1267 return (do_has_ram_image(cdata) || !cdata->_fullpath.empty());
1276 CDReader cdata(_cycler);
1277 return do_get_ram_image_size(cdata);
1287 CDReader cdata(_cycler);
1288 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1289 return do_get_expected_ram_view_size(cdata);
1291 return cdata->_z_size * cdata->_ram_images[0]._page_size;
1306 CDReader cdata(_cycler);
1307 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1308 return do_get_expected_ram_page_size(cdata);
1310 return cdata->_ram_images[0]._page_size;
1320 CDReader cdata(_cycler);
1321 return do_get_expected_ram_image_size(cdata);
1331 CDReader cdata(_cycler);
1332 return do_get_expected_ram_page_size(cdata);
1358 CDWriter cdata(_cycler, unlocked_ensure_ram_image(
true));
1359 return do_get_ram_image(cdata);
1369INLINE Texture::CompressionMode
Texture::
1371 CDReader cdata(_cycler);
1372 return cdata->_ram_image_compression;
1385 cdata->inc_image_modified();
1386 return do_modify_ram_image(cdata);
1406 return do_get_uncompressed_ram_image(cdata);
1418 cdata->inc_image_modified();
1419 return do_make_ram_image(cdata);
1433 do_set_ram_image(cdata, image, compression, page_size);
1442 do_clear_ram_image(cdata);
1457 CDWriter cdata(_cycler,
true);
1458 cdata->_keep_ram_image = keep_ram_image;
1481 Texture::QualityLevel quality_level,
1484 if (do_compress_ram_image(cdata, compression, quality_level, gsg)) {
1485 cdata->inc_image_modified();
1501 if (do_uncompress_ram_image(cdata)) {
1502 cdata->inc_image_modified();
1517 CDReader cdata(_cycler);
1518 return cdata->_ram_images.size();
1531 return do_has_ram_mipmap_image(cdata, n);
1541 return do_has_all_ram_mipmap_images(cdata);
1551 if (n >= 0 && n < (
int)cdata->_ram_images.size()) {
1552 if (cdata->_ram_images[n]._pointer_image ==
nullptr) {
1553 return cdata->_ram_images[n]._image.size();
1556 return do_get_ram_mipmap_page_size(cdata, n) *
1557 do_get_expected_mipmap_z_size(cdata, n) *
1579 return do_get_ram_mipmap_page_size(cdata, n) * do_get_expected_mipmap_z_size(cdata, n);
1594 return do_get_ram_mipmap_page_size(cdata, n);
1604 return do_get_expected_ram_mipmap_image_size(cdata, n);
1616 return do_get_expected_ram_mipmap_view_size(cdata, n);
1627 return do_get_expected_ram_mipmap_page_size(cdata, n);
1640 cdata->inc_image_modified();
1641 return do_modify_ram_mipmap_image(cdata, n);
1653 cdata->inc_image_modified();
1654 return do_make_ram_mipmap_image(cdata, n);
1667 do_set_ram_mipmap_image(cdata, n, image, page_size);
1677 cdata->inc_image_modified();
1678 do_clear_ram_mipmap_images(cdata);
1697 cdata->inc_image_modified();
1698 do_generate_ram_mipmap_images(cdata,
true);
1706 CDReader cdata(_cycler);
1707 return cdata->_simple_x_size;
1715 CDReader cdata(_cycler);
1716 return cdata->_simple_y_size;
1724 CDReader cdata(_cycler);
1725 return !cdata->_simple_ram_image._image.empty();
1735 return cdata->_simple_ram_image._image.size();
1752 CDReader cdata(_cycler);
1753 return cdata->_simple_ram_image._image;
1773 do_set_simple_ram_image(cdata, image, x_size, y_size);
1782 do_clear_simple_ram_image(cdata);
1791 CDReader cdata(_cycler);
1792 return cdata->_properties_modified;
1801 CDReader cdata(_cycler);
1802 return cdata->_image_modified;
1811 CDReader cdata(_cycler);
1812 return cdata->_simple_image_modified;
1822 CDWriter cdata(_cycler,
true);
1823 cdata->_auto_texture_scale = scale;
1833 CDReader cdata(_cycler);
1834 return do_get_auto_texture_scale(cdata);
1844 return (cdata->_auto_texture_scale != ATS_unspecified);
1854 _textures_power_2 = scale;
1865 if (_textures_power_2 == ATS_unspecified) {
1866 return textures_power_2;
1868 return _textures_power_2;
1879 return (_textures_power_2 != ATS_unspecified);
1893 CDWriter cdata(_cycler,
true);
1894 cdata->_filename = filename;
1902 CDWriter cdata(_cycler,
true);
1919 CDWriter cdata(_cycler,
true);
1920 cdata->_alpha_filename = alpha_filename;
1929 CDWriter cdata(_cycler,
true);
1930 cdata->_alpha_filename =
Filename();
1940 CDWriter cdata(_cycler,
true);
1941 cdata->_fullpath = fullpath;
1949 CDWriter cdata(_cycler,
true);
1960 CDWriter cdata(_cycler,
true);
1961 cdata->_alpha_fullpath = alpha_fullpath;
1970 CDWriter cdata(_cycler,
true);
1971 cdata->_alpha_fullpath =
Filename();
1980 CDWriter cdata(_cycler,
true);
1981 do_set_x_size(cdata, x_size);
1990 CDWriter cdata(_cycler,
true);
1991 do_set_y_size(cdata, y_size);
2000 CDWriter cdata(_cycler,
true);
2001 do_set_z_size(cdata, z_size);
2017 CDWriter cdata(_cycler,
true);
2018 do_set_num_views(cdata, num_views);
2027 CDWriter cdata(_cycler,
true);
2028 do_set_format(cdata, format);
2037 CDWriter cdata(_cycler,
true);
2038 do_set_component_type(cdata, component_type);
2049 CDWriter cdata(_cycler,
false);
2050 cdata->_loaded_from_image = flag;
2059 CDReader cdata(_cycler);
2060 return cdata->_loaded_from_image;
2070 CDWriter cdata(_cycler,
false);
2071 cdata->_loaded_from_txo = flag;
2080 CDReader cdata(_cycler);
2081 return cdata->_loaded_from_txo;
2092 CDReader cdata(_cycler);
2093 return cdata->_match_framebuffer_format;
2107 CDWriter cdata(_cycler,
true);
2108 cdata->_match_framebuffer_format = flag;
2117 CDReader cdata(_cycler);
2118 return cdata->_post_load_store_cache;
2132 CDWriter cdata(_cycler,
true);
2133 cdata->_post_load_store_cache = flag;
2146 return do_rescale_texture(cdata);
2156 bool for_padding)
const {
2158 return do_adjust_this_size(cdata, x_size, y_size, name, for_padding);
2164INLINE
size_t Texture::
2165do_get_ram_image_size(
const CData *cdata)
const {
2166 if (cdata->_ram_images.empty()) {
2169 return cdata->_ram_images[0]._image.size();
2175INLINE
bool Texture::
2176do_has_ram_mipmap_image(
const CData *cdata,
int n)
const {
2177 return (n >= 0 && n < (
int)cdata->_ram_images.size() &&
2178 !cdata->_ram_images[n]._image.empty());
2184INLINE
size_t Texture::
2185do_get_expected_ram_image_size(
const CData *cdata)
const {
2186 return do_get_expected_ram_view_size(cdata) * (size_t)cdata->_num_views;
2192INLINE
size_t Texture::
2193do_get_expected_ram_view_size(
const CData *cdata)
const {
2194 return do_get_expected_ram_page_size(cdata) * (size_t)cdata->_z_size;
2200INLINE
size_t Texture::
2201do_get_expected_ram_page_size(
const CData *cdata)
const {
2202 return (
size_t)(cdata->_x_size * cdata->_y_size * cdata->_num_components * cdata->_component_width);
2208INLINE
size_t Texture::
2209do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const {
2210 return do_get_expected_ram_mipmap_view_size(cdata, n) * (size_t)cdata->_num_views;
2216INLINE
size_t Texture::
2217do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const {
2218 return do_get_expected_ram_mipmap_page_size(cdata, n) * (size_t)do_get_expected_mipmap_z_size(cdata, n);
2224INLINE
size_t Texture::
2225do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const {
2226 return (
size_t)(do_get_expected_mipmap_x_size(cdata, n) * do_get_expected_mipmap_y_size(cdata, n) * cdata->_num_components * cdata->_component_width);
2233do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const {
2234 return do_get_expected_mipmap_z_size(cdata, n) * cdata->_num_views;
2240INLINE
void Texture::
2241do_clear_ram_image(CData *cdata) {
2242 cdata->_ram_image_compression = CM_off;
2243 cdata->_ram_images.clear();
2249INLINE AutoTextureScale Texture::
2250do_get_auto_texture_scale(
const CData *cdata)
const {
2251 if (cdata->_auto_texture_scale == ATS_unspecified) {
2254 return cdata->_auto_texture_scale;
2263INLINE
void Texture::
2264store_unscaled_byte(
unsigned char *&p,
int value) {
2265 (*p++) = (uchar)value;
2273INLINE
void Texture::
2274store_unscaled_short(
unsigned char *&p,
int value) {
2279 v.us = (ushort)value;
2290INLINE
void Texture::
2291store_scaled_byte(
unsigned char *&p,
int value,
double scale) {
2292 store_unscaled_byte(p, (
int)(value * scale));
2301INLINE
void Texture::
2302store_scaled_short(
unsigned char *&p,
int value,
double scale) {
2303 store_unscaled_short(p, (
int)(value * scale));
2311INLINE
double Texture::
2312get_unsigned_byte(
const unsigned char *&p) {
2313 return (
double)(*p++) / 255.0;
2321INLINE
double Texture::
2322get_unsigned_short(
const unsigned char *&p) {
2329 return (
double)v.us / 65535.0;
2337INLINE
double Texture::
2338get_unsigned_int(
const unsigned char *&p) {
2347 return (
double)v.ui / 4294967295.0;
2355INLINE
double Texture::
2356get_unsigned_int_24(
const unsigned char *&p) {
2365 return (
double)(v.ui & 0xffffff) / (
double)0xffffff;
2373INLINE
double Texture::
2374get_float(
const unsigned char *&p) {
2375 double v = *((
float *)p);
2385INLINE
double Texture::
2386get_half_float(
const unsigned char *&p) {
2391 uint16_t in = *(uint16_t *)p;
2393 uint32_t t1 = in & 0x7fff;
2394 uint32_t t2 = in & 0x8000;
2395 uint32_t t3 = in & 0x7c00;
2400 t1 = (t3 == 0 ? 0 : t1);
2414INLINE
bool Texture::
2415is_txo_filename(
const Filename &fullpath) {
2418 if (extension ==
"pz" || extension ==
"gz") {
2422 return (extension ==
"txo");
2429INLINE
bool Texture::
2430is_dds_filename(
const Filename &fullpath) {
2433 if (extension ==
"pz" || extension ==
"gz") {
2437 return (
downcase(extension) ==
"dds");
2444INLINE
bool Texture::
2445is_ktx_filename(
const Filename &fullpath) {
2448 if (extension ==
"pz" || extension ==
"gz") {
2452 return (
downcase(extension) ==
"ktx");
2458INLINE
void Texture::CData::
2459inc_properties_modified() {
2460 ++_properties_modified;
2466INLINE
void Texture::CData::
2467inc_image_modified() {
2474INLINE
void Texture::CData::
2475inc_simple_image_modified() {
2476 ++_simple_image_modified;
2482INLINE Texture::RamImage::
2485 _pointer_image(nullptr)
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
The name of a file, such as a texture file or an Egg file.
std::string get_extension() const
Returns the file extension.
std::string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Specifies parameters that may be passed to the loader.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
Represents a set of settings that indicate how a texture is sampled.
static bool is_mipmap(FilterType type)
Returns true if the indicated filter type requires the use of mipmaps, or false if it does not.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
size_t get_ram_mipmap_image_size(int n) const
Returns the number of bytes used by the in-memory image for mipmap level n, or 0 if there is no in-me...
void setup_2d_texture()
Sets the texture as an empty 2-d texture with no dimensions.
get_post_load_store_cache
Returns the setting of the post_load_store_cache flag.
set_compression
Requests that this particular Texture be compressed when it is loaded into texture memory.
set_alpha_fullpath
Sets the full pathname to the file that contains the image's alpha channel contents,...
CPTA_uchar get_uncompressed_ram_image()
Returns the system-RAM image associated with the texture, in an uncompressed form if at all possible.
get_format
Returns the format of the texture, which represents both the semantic meaning of the texels and,...
get_minfilter
Returns the filter mode of the texture for minification.
get_ram_image_size
Returns the total number of bytes used by the in-memory image, across all pages and views,...
size_t get_expected_ram_mipmap_view_size(int n) const
Returns the number of bytes that *ought* to be used by each view of the in- memory image for mipmap l...
has_filename
Returns true if the filename has been set and is available.
void generate_ram_mipmap_images()
Automatically fills in the n mipmap levels of the Texture, based on the texture's source image.
void clear_ram_mipmap_images()
Discards the current system-RAM image for all mipmap levels, except level 0 (the base image).
set_match_framebuffer_format
Sets the special flag that, if true, indicates to the GSG that the Texture's format should be chosen ...
void clear_image()
Clears the texture data without changing its format or resolution.
PTA_uchar modify_ram_image()
Returns a modifiable pointer to the system-RAM image.
void setup_cube_map_array(int num_cube_maps)
Sets the texture as cube map array with N cube maps.
size_t get_expected_ram_mipmap_image_size(int n) const
Returns the number of bytes that *ought* to be used by the in-memory image for mipmap level n,...
get_alpha_fullpath
Returns the alpha_fullpath that has been set.
bool has_auto_texture_scale() const
Returns true if set_auto_texture_scale() has been set to something other than ATS_unspecified for thi...
set_wrap_u
This setting determines what happens when the texture is sampled with a U value outside the range 0....
void setup_2d_texture_array(int z_size=1)
Sets the texture as an empty 2-d texture array with no dimensions (though if you know the depth ahead...
set_z_size
Changes the z size indicated for the texture.
set_num_views
Sets the number of "views" within a texture.
get_ram_page_size
Returns the number of bytes used by the in-memory image per page, or 0 if there is no in-memory image...
get_render_to_texture
Returns a flag on the texture that indicates whether the texture is intended to be used as a direct-r...
int get_expected_mipmap_num_pages(int n) const
Returns the total number of pages that the nth mipmap level should have, based on the texture's size.
get_num_views
Returns the number of "views" in the texture.
get_compression
Returns the compression mode requested for this particular texture, or CM_off if the texture is not t...
get_wrap_w
Returns the wrap mode of the texture in the W direction.
bool has_ram_image() const
Returns true if the Texture has its image contents available in main RAM, false if it exists only in ...
get_texture_type
Returns the overall interpretation of the texture.
bool write(const Filename &fullpath)
Writes the texture to the named filename.
get_filename
Returns the filename that has been set.
get_default_sampler
This returns the default sampler state for this texture, containing the wrap and filter properties sp...
int get_pad_y_size() const
Returns size of the pad region.
CPTA_uchar get_ram_image()
Returns the system-RAM image data associated with the texture.
get_simple_ram_image
Returns the image data associated with the "simple" texture image.
has_fullpath
Returns true if the fullpath has been set and is available.
get_ram_image_compression
Returns the compression mode in which the ram image is already stored pre- compressed.
get_effective_anisotropic_degree
Returns the degree of anisotropic filtering that should be applied to the texture.
set_format
Changes the format value for the texture components.
get_orig_file_z_size
Returns the Z size of the original disk image that this Texture was loaded from (if it came from a di...
get_component_width
Returns the number of bytes stored for each color component of a texel.
void setup_texture(TextureType texture_type, int x_size, int y_size, int z_size, ComponentType component_type, Format format)
Sets the texture to the indicated type and dimensions, presumably in preparation for calling read() o...
get_alpha_filename
Returns the alpha_filename that has been set.
int get_expected_mipmap_z_size(int n) const
Returns the z_size that the nth mipmap level should have, based on the texture's size.
bool load(const PNMImage &pnmimage, const LoaderOptions &options=LoaderOptions())
Replaces the texture with the indicated image.
clear_fullpath
Removes the alpha fullpath, if it was previously set.
bool reload()
Re-reads the Texture from its disk file.
vector_uchar get_clear_data() const
Returns the raw image data for a single pixel if it were set to the clear color.
void clear_simple_ram_image()
Discards the current "simple" image.
get_effective_minfilter
Returns the filter mode of the texture for minification, with special treatment for FT_default.
bool rescale_texture()
This method is similar to consider_rescale(), but instead of scaling a separate PNMImage,...
set_anisotropic_degree
Specifies the level of anisotropic filtering to apply to the texture.
set_render_to_texture
Sets a flag on the texture that indicates whether the texture is intended to be used as a direct-rend...
set_loaded_from_image
Sets the flag that indicates the texture has been loaded from a disk file or PNMImage.
set_quality_level
Sets a hint to the renderer about the desired performance / quality tradeoff for this particular text...
set_clear_color
Sets the color that will be used to fill the texture image in absence of any image data.
get_expected_num_mipmap_levels
Returns the number of mipmap levels that should be defined for this texture, given the texture's size...
clear_alpha_fullpath
Removes the alpha fullpath, if it was previously set.
void setup_cube_map()
Sets the texture as an empty cube map texture with no dimensions.
get_anisotropic_degree
Returns the degree of anisotropic filtering that should be applied to the texture.
has_alpha_fullpath
Returns true if the alpha_fullpath has been set and is available.
get_match_framebuffer_format
Returns true if the special flag was set that indicates to the GSG that the Texture's format should b...
PTA_uchar modify_ram_mipmap_image(int n)
Returns a modifiable pointer to the system-RAM image for the nth mipmap level.
get_properties_modified
Returns a sequence number which is guaranteed to change at least every time the texture properties (u...
clear_alpha_filename
Removes the alpha filename, if it was previously set.
bool has_compression() const
Returns true if the texture indicates it wants to be compressed, either with CM_on or higher,...
get_y_size
Returns the height of the texture image in texels.
bool compress_ram_image(CompressionMode compression=CM_on, QualityLevel quality_level=QL_default, GraphicsStateGuardianBase *gsg=nullptr)
Attempts to compress the texture's RAM image internally, to a format supported by the indicated GSG.
bool load_sub_image(const PNMImage &pnmimage, int x, int y, int z=0, int n=0)
Stores the indicated image in a region of the texture.
size_t get_ram_mipmap_view_size(int n) const
Returns the number of bytes used by the in-memory image per view for mipmap level n,...
get_magfilter
Returns the filter mode of the texture for magnification.
LVecBase2 get_tex_scale() const
Returns a scale pair that is suitable for applying to geometry via NodePath::set_tex_scale(),...
get_z_size
Returns the depth of the texture image in texels.
int get_pad_x_size() const
Returns size of the pad region.
get_image_modified
Returns a sequence number which is guaranteed to change at least every time the texture image data (i...
set_x_size
Changes the x size indicated for the texture.
get_quality_level
Returns the current quality_level hint.
get_simple_image_modified
Returns a sequence number which is guaranteed to change at least every time the texture's "simple" im...
void set_ram_mipmap_image(int n, CPTA_uchar image, size_t page_size=0)
Replaces the current system-RAM image for the indicated mipmap level with the new data.
size_t get_expected_ram_mipmap_page_size(int n) const
Returns the number of bytes that should be used per each Z page of the 3-d texture,...
void setup_1d_texture()
Sets the texture as an empty 1-d texture with no dimensions.
set_minfilter
Sets the filtering method that should be used when viewing the texture from a distance.
get_effective_magfilter
Returns the filter mode of the texture for magnification, with special treatment for FT_default.
has_alpha_filename
Returns true if the alpha_filename has been set and is available.
set_magfilter
Sets the filtering method that should be used when viewing the texture up close.
bool might_have_ram_image() const
Returns true if the texture's image contents are currently available in main RAM, or there is reason ...
PTA_uchar make_ram_mipmap_image(int n)
Discards the current system-RAM image for the nth mipmap level, if any, and allocates a new buffer of...
static AutoTextureScale get_textures_power_2()
This flag returns ATS_none, ATS_up, or ATS_down and controls the scaling of textures in general.
int get_pad_z_size() const
Returns size of the pad region.
bool has_ram_mipmap_image(int n) const
Returns true if the Texture has the nth mipmap level available in system memory, false otherwise.
get_loaded_from_image
Returns the flag that indicates the texture has been loaded from a disk file or PNMImage.
get_auto_texture_scale
Returns the power-of-2 texture-scaling mode that will be applied to this particular texture when it i...
void setup_buffer_texture(int size, ComponentType component_type, Format format, GeomEnums::UsageHint usage)
Sets the texture as an empty buffer texture with the specified size and properties.
void set_pad_size(int x=0, int y=0, int z=0)
Sets the size of the pad region.
int get_expected_mipmap_x_size(int n) const
Returns the x_size that the nth mipmap level should have, based on the texture's size.
void set_simple_ram_image(CPTA_uchar image, int x_size, int y_size)
Replaces the internal "simple" texture image.
get_num_components
Returns the number of color components for each texel of the texture image.
get_effective_quality_level
Returns the current quality_level hint, or the global default quality_level if this texture doesn't s...
void clear_ram_image()
Discards the current system-RAM image.
bool uses_mipmaps() const
Returns true if the minfilter settings on this texture indicate the use of mipmapping,...
get_fullpath
Returns the fullpath that has been set.
set_default_sampler
This sets the default sampler state for this texture, containing the wrap and filter properties speci...
has_clear_color
Returns true if a color was previously set using set_clear_color.
get_wrap_u
Returns the wrap mode of the texture in the U direction.
set_loaded_from_txo
Sets the flag that indicates the texture has been loaded from a txo file.
get_num_pages
Returns the total number of pages in the texture.
has_simple_ram_image
Returns true if the Texture has a "simple" image available in main RAM.
set_auto_texture_scale
Specifies the power-of-2 texture-scaling mode that will be applied to this particular texture when it...
static void set_textures_power_2(AutoTextureScale scale)
Set this flag to ATS_none, ATS_up, ATS_down, or ATS_pad to control the scaling of textures in general...
size_t get_simple_ram_image_size() const
Returns the number of bytes used by the "simple" image, or 0 if there is no simple image.
get_orig_file_x_size
Returns the X size of the original disk image that this Texture was loaded from (if it came from a di...
size_t get_ram_mipmap_page_size(int n) const
Returns the number of bytes used by the in-memory image per page for mipmap level n,...
get_x_size
Returns the width of the texture image in texels.
bool has_uncompressed_ram_image() const
Returns true if the Texture has its image contents available in main RAM and is uncompressed,...
bool has_all_ram_mipmap_images() const
Returns true if all expected mipmap levels have been defined and exist in the system RAM,...
clear_clear_color
The opposite of set_clear_color.
get_simple_y_size
Returns the height of the "simple" image in texels.
get_expected_ram_page_size
Returns the number of bytes that should be used per each Z page of the 3-d texture.
set_fullpath
Sets the full pathname to the file that contains the image's contents, as found along the search path...
int get_expected_mipmap_y_size(int n) const
Returns the y_size that the nth mipmap level should have, based on the texture's size.
bool uncompress_ram_image()
Attempts to uncompress the texture's RAM image internally.
set_y_size
Changes the y size indicated for the texture.
get_expected_ram_image_size
Returns the number of bytes that *ought* to be used by the in-memory image, based on the texture para...
set_post_load_store_cache
Sets the post_load_store_cache flag.
set_wrap_w
The W wrap direction is only used for 3-d textures.
PTA_uchar make_ram_image()
Discards the current system-RAM image for the texture, if any, and allocates a new buffer of the appr...
get_component_type
Returns the numeric interpretation of each component of the texture.
void set_ram_image(CPTA_uchar image, CompressionMode compression=CM_off, size_t page_size=0)
Replaces the current system-RAM image with the new data.
bool adjust_this_size(int &x_size, int &y_size, const std::string &name, bool for_padding) const
Works like adjust_size, but also considers the texture class.
get_simple_x_size
Returns the width of the "simple" image in texels.
get_loaded_from_txo
Returns the flag that indicates the texture has been loaded from a txo file.
get_wrap_v
Returns the wrap mode of the texture in the V direction.
get_border_color
Returns the solid color of the texture's border.
get_clear_color
Returns the color that was previously set using set_clear_color.
set_keep_ram_image
Sets the flag that indicates whether this Texture is eligible to have its main RAM copy of the textur...
clear_filename
Removes the alpha filename, if it was previously set.
set_border_color
Specifies the solid color of the texture's border.
get_ram_view_size
Returns the number of bytes used by the in-memory image per view, or 0 if there is no in-memory image...
set_alpha_filename
Sets the name of the file that contains the image's alpha channel contents.
set_wrap_v
This setting determines what happens when the texture is sampled with a V value outside the range 0....
set_filename
Sets the name of the file that contains the image's contents.
bool store(PNMImage &pnmimage) const
Saves the texture to the indicated PNMImage, but does not write it to disk.
static bool has_textures_power_2()
If true, then get_textures_power_2 has been set using set_textures_power_2.
set_component_type
Changes the data value for the texture components.
get_orig_file_y_size
Returns the Y size of the original disk image that this Texture was loaded from (if it came from a di...
get_num_ram_mipmap_images
Returns the maximum number of mipmap level images available in system memory.
void setup_3d_texture(int z_size=1)
Sets the texture as an empty 3-d texture with no dimensions (though if you know the depth ahead of ti...
get_usage_hint
Returns the usage hint specified for buffer textures, or UH_unspecified for all other texture types.
This is a sequence number that increments monotonically.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.