28 CDWriter cdata_tex(tex->_cycler,
true);
29 cdata_tex->inc_properties_modified();
30 cdata_tex->inc_image_modified();
31 cdata_tex->inc_simple_image_modified();
41 CDWriter cdata(_cycler,
true);
52 setup_texture(Texture::TextureType texture_type,
int x_size,
int y_size,
53 int z_size, Texture::ComponentType component_type,
54 Texture::Format format) {
56 do_setup_texture(cdata, texture_type, x_size, y_size, z_size,
57 component_type, format);
78 setup_texture(TT_1d_texture, x_size, 1, 1, component_type, format);
100 setup_texture(TT_2d_texture, x_size, y_size, 1, component_type, format);
121 ComponentType component_type, Format format) {
122 setup_texture(TT_3d_texture, x_size, y_size, z_size, component_type, format);
145 ComponentType component_type, Format format) {
146 setup_texture(TT_2d_texture_array, x_size, y_size, z_size, component_type, format);
170 setup_texture(TT_cube_map, size, size, 6, component_type, format);
199 setup_texture(TT_cube_map_array, size, size, num_cube_maps * 6, component_type, format);
212 GeomEnums::UsageHint usage) {
213 setup_texture(TT_buffer_texture, size, 1, 1, component_type, format);
215 cdata->_usage_hint = usage;
232 do_clear_ram_image(cdata);
233 do_clear_simple_ram_image(cdata);
234 cdata->inc_image_modified();
235 cdata->inc_simple_image_modified();
241 INLINE
bool Texture::
242 has_clear_color()
const {
243 CDReader cdata(_cycler);
244 return cdata->_has_clear_color;
250 INLINE LColor Texture::
251 get_clear_color()
const {
252 CDReader cdata(_cycler);
253 return cdata->_clear_color;
267 CDWriter cdata(_cycler,
true);
268 cdata->_clear_color = color;
269 cdata->_has_clear_color =
true;
276 INLINE
void Texture::
277 clear_clear_color() {
278 CDWriter cdata(_cycler,
true);
279 cdata->_has_clear_color =
true;
289 vector_uchar data(16);
290 data.resize(do_get_clear_data(cdata, &data[0]));
302 return do_write(cdata, fullpath, 0, 0,
false,
false);
348 bool write_pages,
bool write_mipmaps) {
350 return do_write(cdata, fullpath, z, n, write_pages, write_mipmaps);
360 cdata->inc_properties_modified();
361 cdata->inc_image_modified();
362 if (do_load_one(cdata, pnmimage, get_name(), 0, 0, options)) {
363 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
364 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
376 cdata->inc_properties_modified();
377 cdata->inc_image_modified();
378 if (do_load_one(cdata, pnmimage, get_name(), z, n, options)) {
391 cdata->inc_properties_modified();
392 cdata->inc_image_modified();
393 if (do_load_one(cdata, pfm, get_name(), 0, 0, options)) {
394 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
395 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
407 cdata->inc_properties_modified();
408 cdata->inc_image_modified();
409 if (do_load_one(cdata, pfm, get_name(), z, n, options)) {
425 return do_load_sub_image(cdata, image, x, y, z, n);
434 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, 0, 0);
443 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, z, n);
452 return ((
Texture *)
this)->do_store_one(cdata, pfm, 0, 0);
461 return ((
Texture *)
this)->do_store_one(cdata, pfm, z, n);
474 return do_reload(cdata);
481 INLINE
bool Texture::
482 has_filename()
const {
483 CDReader cdata(_cycler);
484 return !cdata->_filename.empty();
492 get_filename()
const {
493 CDReader cdata(_cycler);
494 return cdata->_filename;
501 INLINE
bool Texture::
502 has_alpha_filename()
const {
503 CDReader cdata(_cycler);
504 return !cdata->_alpha_filename.empty();
513 get_alpha_filename()
const {
514 CDReader cdata(_cycler);
515 return cdata->_alpha_filename;
522 INLINE
bool Texture::
523 has_fullpath()
const {
524 CDReader cdata(_cycler);
525 return !cdata->_fullpath.empty();
533 get_fullpath()
const {
534 CDReader cdata(_cycler);
535 return cdata->_fullpath;
542 INLINE
bool Texture::
543 has_alpha_fullpath()
const {
544 CDReader cdata(_cycler);
545 return !cdata->_alpha_fullpath.empty();
554 get_alpha_fullpath()
const {
555 CDReader cdata(_cycler);
556 return cdata->_alpha_fullpath;
565 CDReader cdata(_cycler);
566 return cdata->_x_size;
575 CDReader cdata(_cycler);
576 return cdata->_y_size;
585 CDReader cdata(_cycler);
586 return cdata->_z_size;
599 get_num_views()
const {
600 CDReader cdata(_cycler);
601 return cdata->_num_views;
612 get_num_pages()
const {
622 return cdata->_pad_x_size;
631 return cdata->_pad_y_size;
640 return cdata->_pad_z_size;
657 if (cdata->_pad_x_size == 0 || cdata->_pad_y_size == 0 ||
658 cdata->_x_size == 0 || cdata->_y_size == 0) {
659 LVecBase2(1.0f, 1.0f);
661 return LVecBase2((PN_stdfloat)(cdata->_x_size - cdata->_pad_x_size) / (PN_stdfloat)cdata->_x_size,
662 (PN_stdfloat)(cdata->_y_size - cdata->_pad_y_size) / (PN_stdfloat)cdata->_y_size);
679 do_set_pad_size(cdata, x, y, z);
688 get_orig_file_x_size()
const {
689 CDReader cdata(_cycler);
690 return cdata->_orig_file_x_size;
699 get_orig_file_y_size()
const {
700 CDReader cdata(_cycler);
701 return cdata->_orig_file_y_size;
710 get_orig_file_z_size()
const {
713 CDReader cdata(_cycler);
714 return cdata->_z_size;
723 get_num_components()
const {
724 CDReader cdata(_cycler);
725 return cdata->_num_components;
733 get_component_width()
const {
734 CDReader cdata(_cycler);
735 return cdata->_component_width;
741 INLINE Texture::TextureType Texture::
742 get_texture_type()
const {
743 CDReader cdata(_cycler);
744 return cdata->_texture_type;
751 INLINE Texture::Format Texture::
753 CDReader cdata(_cycler);
754 return cdata->_format;
760 INLINE Texture::ComponentType Texture::
761 get_component_type()
const {
762 CDReader cdata(_cycler);
763 return cdata->_component_type;
770 INLINE GeomEnums::UsageHint Texture::
771 get_usage_hint()
const {
772 CDReader cdata(_cycler);
773 return cdata->_usage_hint;
786 CDWriter cdata(_cycler,
true);
787 do_set_wrap_u(cdata, wrap);
800 CDWriter cdata(_cycler,
true);
801 do_set_wrap_v(cdata, wrap);
812 CDWriter cdata(_cycler,
true);
813 do_set_wrap_w(cdata, wrap);
825 CDWriter cdata(_cycler,
true);
826 do_set_minfilter(cdata, filter);
838 CDWriter cdata(_cycler,
true);
839 do_set_magfilter(cdata, filter);
856 CDWriter cdata(_cycler,
true);
857 do_set_anisotropic_degree(cdata, anisotropic_degree);
870 CDWriter cdata(_cycler,
true);
871 do_set_border_color(cdata, color);
890 CDWriter cdata(_cycler,
true);
891 do_set_compression(cdata, compression);
909 CDWriter cdata(_cycler,
false);
910 cdata->_render_to_texture = render_to_texture;
919 get_default_sampler()
const {
920 CDReader cdata(_cycler);
921 return cdata->_default_sampler;
937 CDWriter cdata(_cycler,
true);
938 cdata->_default_sampler = sampler;
939 cdata->inc_properties_modified();
948 INLINE SamplerState::WrapMode Texture::
950 CDReader cdata(_cycler);
951 return cdata->_default_sampler.get_wrap_u();
960 INLINE SamplerState::WrapMode Texture::
962 CDReader cdata(_cycler);
963 return cdata->_default_sampler.get_wrap_v();
973 INLINE SamplerState::WrapMode Texture::
975 CDReader cdata(_cycler);
976 return cdata->_default_sampler.get_wrap_w();
987 INLINE SamplerState::FilterType Texture::
988 get_minfilter()
const {
989 CDReader cdata(_cycler);
990 return cdata->_default_sampler.get_minfilter();
1001 INLINE SamplerState::FilterType Texture::
1002 get_magfilter()
const {
1003 CDReader cdata(_cycler);
1004 return cdata->_default_sampler.get_magfilter();
1015 SamplerState::FilterType Texture::
1016 get_effective_minfilter()
const {
1017 CDReader cdata(_cycler);
1018 return cdata->_default_sampler.get_effective_minfilter();
1029 SamplerState::FilterType Texture::
1030 get_effective_magfilter()
const {
1031 CDReader cdata(_cycler);
1032 return cdata->_default_sampler.get_effective_magfilter();
1043 INLINE
int Texture::
1044 get_anisotropic_degree()
const {
1045 CDReader cdata(_cycler);
1046 return cdata->_default_sampler.get_anisotropic_degree();
1057 INLINE
int Texture::
1058 get_effective_anisotropic_degree()
const {
1059 CDReader cdata(_cycler);
1060 return cdata->_default_sampler.get_effective_anisotropic_degree();
1071 INLINE LColor Texture::
1072 get_border_color()
const {
1073 CDReader cdata(_cycler);
1074 return cdata->_default_sampler.get_border_color();
1086 INLINE Texture::CompressionMode Texture::
1087 get_compression()
const {
1088 CDReader cdata(_cycler);
1089 return cdata->_compression;
1104 return do_has_compression(cdata);
1116 INLINE
bool Texture::
1117 get_render_to_texture()
const {
1118 CDReader cdata(_cycler);
1119 return cdata->_render_to_texture;
1139 CDWriter cdata(_cycler,
true);
1140 do_set_quality_level(cdata, quality_level);
1147 INLINE Texture::QualityLevel Texture::
1148 get_quality_level()
const {
1149 CDReader cdata(_cycler);
1150 return cdata->_quality_level;
1158 INLINE Texture::QualityLevel Texture::
1159 get_effective_quality_level()
const {
1160 CDReader cdata(_cycler);
1161 if (cdata->_quality_level == QL_default) {
1162 return texture_quality_level;
1164 return cdata->_quality_level;
1174 INLINE
int Texture::
1175 get_expected_num_mipmap_levels()
const {
1176 CDReader cdata(_cycler);
1177 return do_get_expected_num_mipmap_levels(cdata);
1187 return do_get_expected_mipmap_x_size(cdata, n);
1197 return do_get_expected_mipmap_y_size(cdata, n);
1207 return do_get_expected_mipmap_z_size(cdata, n);
1219 return do_get_expected_mipmap_num_pages(cdata, n);
1244 return do_has_ram_image(cdata);
1254 return do_has_uncompressed_ram_image(cdata);
1266 return (do_has_ram_image(cdata) || !cdata->_fullpath.empty());
1273 INLINE
size_t Texture::
1274 get_ram_image_size()
const {
1275 CDReader cdata(_cycler);
1276 return do_get_ram_image_size(cdata);
1284 INLINE
size_t Texture::
1285 get_ram_view_size()
const {
1286 CDReader cdata(_cycler);
1287 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1288 return do_get_expected_ram_view_size(cdata);
1290 return cdata->_z_size * cdata->_ram_images[0]._page_size;
1303 INLINE
size_t Texture::
1304 get_ram_page_size()
const {
1305 CDReader cdata(_cycler);
1306 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1307 return do_get_expected_ram_page_size(cdata);
1309 return cdata->_ram_images[0]._page_size;
1317 INLINE
size_t Texture::
1318 get_expected_ram_image_size()
const {
1319 CDReader cdata(_cycler);
1320 return do_get_expected_ram_image_size(cdata);
1328 INLINE
size_t Texture::
1329 get_expected_ram_page_size()
const {
1330 CDReader cdata(_cycler);
1331 return do_get_expected_ram_page_size(cdata);
1357 CDWriter cdata(_cycler, unlocked_ensure_ram_image(
true));
1358 return do_get_ram_image(cdata);
1368 INLINE Texture::CompressionMode Texture::
1369 get_ram_image_compression()
const {
1370 CDReader cdata(_cycler);
1371 return cdata->_ram_image_compression;
1384 cdata->inc_image_modified();
1385 return do_modify_ram_image(cdata);
1405 return do_get_uncompressed_ram_image(cdata);
1417 cdata->inc_image_modified();
1418 return do_make_ram_image(cdata);
1432 do_set_ram_image(cdata, image, compression, page_size);
1441 do_clear_ram_image(cdata);
1456 CDWriter cdata(_cycler,
true);
1457 cdata->_keep_ram_image = keep_ram_image;
1480 Texture::QualityLevel quality_level,
1483 if (do_compress_ram_image(cdata, compression, quality_level, gsg)) {
1484 cdata->inc_image_modified();
1500 if (do_uncompress_ram_image(cdata)) {
1501 cdata->inc_image_modified();
1514 INLINE
int Texture::
1515 get_num_ram_mipmap_images()
const {
1516 CDReader cdata(_cycler);
1517 return cdata->_ram_images.size();
1530 return do_has_ram_mipmap_image(cdata, n);
1540 return do_has_all_ram_mipmap_images(cdata);
1550 if (n >= 0 && n < (
int)cdata->_ram_images.size()) {
1551 if (cdata->_ram_images[n]._pointer_image ==
nullptr) {
1552 return cdata->_ram_images[n]._image.size();
1555 return do_get_ram_mipmap_page_size(cdata, n) *
1556 do_get_expected_mipmap_z_size(cdata, n) *
1578 return do_get_ram_mipmap_page_size(cdata, n) * do_get_expected_mipmap_z_size(cdata, n);
1593 return do_get_ram_mipmap_page_size(cdata, n);
1603 return do_get_expected_ram_mipmap_image_size(cdata, n);
1615 return do_get_expected_ram_mipmap_view_size(cdata, n);
1626 return do_get_expected_ram_mipmap_page_size(cdata, n);
1639 cdata->inc_image_modified();
1640 return do_modify_ram_mipmap_image(cdata, n);
1652 cdata->inc_image_modified();
1653 return do_make_ram_mipmap_image(cdata, n);
1666 do_set_ram_mipmap_image(cdata, n, image, page_size);
1676 cdata->inc_image_modified();
1677 do_clear_ram_mipmap_images(cdata);
1696 cdata->inc_image_modified();
1697 do_generate_ram_mipmap_images(cdata,
true);
1703 INLINE
int Texture::
1704 get_simple_x_size()
const {
1705 CDReader cdata(_cycler);
1706 return cdata->_simple_x_size;
1712 INLINE
int Texture::
1713 get_simple_y_size()
const {
1714 CDReader cdata(_cycler);
1715 return cdata->_simple_y_size;
1721 INLINE
bool Texture::
1722 has_simple_ram_image()
const {
1723 CDReader cdata(_cycler);
1724 return !cdata->_simple_ram_image._image.empty();
1734 return cdata->_simple_ram_image._image.size();
1750 get_simple_ram_image()
const {
1751 CDReader cdata(_cycler);
1752 return cdata->_simple_ram_image._image;
1772 do_set_simple_ram_image(cdata, image, x_size, y_size);
1781 do_clear_simple_ram_image(cdata);
1789 get_properties_modified()
const {
1790 CDReader cdata(_cycler);
1791 return cdata->_properties_modified;
1799 get_image_modified()
const {
1800 CDReader cdata(_cycler);
1801 return cdata->_image_modified;
1809 get_simple_image_modified()
const {
1810 CDReader cdata(_cycler);
1811 return cdata->_simple_image_modified;
1821 CDWriter cdata(_cycler,
true);
1822 cdata->_auto_texture_scale = scale;
1830 INLINE AutoTextureScale Texture::
1831 get_auto_texture_scale()
const {
1832 CDReader cdata(_cycler);
1833 return do_get_auto_texture_scale(cdata);
1843 return (cdata->_auto_texture_scale != ATS_unspecified);
1853 _textures_power_2 = scale;
1864 if (_textures_power_2 == ATS_unspecified) {
1865 return textures_power_2;
1867 return _textures_power_2;
1878 return (_textures_power_2 != ATS_unspecified);
1892 CDWriter cdata(_cycler,
true);
1893 cdata->_filename = filename;
1899 INLINE
void Texture::
1901 CDWriter cdata(_cycler,
true);
1918 CDWriter cdata(_cycler,
true);
1919 cdata->_alpha_filename = alpha_filename;
1926 INLINE
void Texture::
1927 clear_alpha_filename() {
1928 CDWriter cdata(_cycler,
true);
1929 cdata->_alpha_filename =
Filename();
1939 CDWriter cdata(_cycler,
true);
1940 cdata->_fullpath = fullpath;
1946 INLINE
void Texture::
1948 CDWriter cdata(_cycler,
true);
1959 CDWriter cdata(_cycler,
true);
1960 cdata->_alpha_fullpath = alpha_fullpath;
1967 INLINE
void Texture::
1968 clear_alpha_fullpath() {
1969 CDWriter cdata(_cycler,
true);
1970 cdata->_alpha_fullpath =
Filename();
1979 CDWriter cdata(_cycler,
true);
1980 do_set_x_size(cdata, x_size);
1989 CDWriter cdata(_cycler,
true);
1990 do_set_y_size(cdata, y_size);
1999 CDWriter cdata(_cycler,
true);
2000 do_set_z_size(cdata, z_size);
2016 CDWriter cdata(_cycler,
true);
2017 do_set_num_views(cdata, num_views);
2026 CDWriter cdata(_cycler,
true);
2027 do_set_format(cdata, format);
2036 CDWriter cdata(_cycler,
true);
2037 do_set_component_type(cdata, component_type);
2048 CDWriter cdata(_cycler,
false);
2049 cdata->_loaded_from_image = flag;
2056 INLINE
bool Texture::
2057 get_loaded_from_image()
const {
2058 CDReader cdata(_cycler);
2059 return cdata->_loaded_from_image;
2069 CDWriter cdata(_cycler,
false);
2070 cdata->_loaded_from_txo = flag;
2077 INLINE
bool Texture::
2078 get_loaded_from_txo()
const {
2079 CDReader cdata(_cycler);
2080 return cdata->_loaded_from_txo;
2089 INLINE
bool Texture::
2090 get_match_framebuffer_format()
const {
2091 CDReader cdata(_cycler);
2092 return cdata->_match_framebuffer_format;
2106 CDWriter cdata(_cycler,
true);
2107 cdata->_match_framebuffer_format = flag;
2114 INLINE
bool Texture::
2115 get_post_load_store_cache()
const {
2116 CDReader cdata(_cycler);
2117 return cdata->_post_load_store_cache;
2131 CDWriter cdata(_cycler,
true);
2132 cdata->_post_load_store_cache = flag;
2145 return do_rescale_texture(cdata);
2155 bool for_padding)
const {
2157 return do_adjust_this_size(cdata, x_size, y_size, name, for_padding);
2163 INLINE
size_t Texture::
2164 do_get_ram_image_size(
const CData *cdata)
const {
2165 if (cdata->_ram_images.empty()) {
2168 return cdata->_ram_images[0]._image.size();
2174 INLINE
bool Texture::
2175 do_has_ram_mipmap_image(
const CData *cdata,
int n)
const {
2176 return (n >= 0 && n < (
int)cdata->_ram_images.size() &&
2177 !cdata->_ram_images[n]._image.empty());
2183 INLINE
size_t Texture::
2184 do_get_expected_ram_image_size(
const CData *cdata)
const {
2185 return do_get_expected_ram_view_size(cdata) * (size_t)cdata->_num_views;
2191 INLINE
size_t Texture::
2192 do_get_expected_ram_view_size(
const CData *cdata)
const {
2193 return do_get_expected_ram_page_size(cdata) * (size_t)cdata->_z_size;
2199 INLINE
size_t Texture::
2200 do_get_expected_ram_page_size(
const CData *cdata)
const {
2201 return (
size_t)(cdata->_x_size * cdata->_y_size * cdata->_num_components * cdata->_component_width);
2207 INLINE
size_t Texture::
2208 do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const {
2209 return do_get_expected_ram_mipmap_view_size(cdata, n) * (size_t)cdata->_num_views;
2215 INLINE
size_t Texture::
2216 do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const {
2217 return do_get_expected_ram_mipmap_page_size(cdata, n) * (size_t)do_get_expected_mipmap_z_size(cdata, n);
2223 INLINE
size_t Texture::
2224 do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const {
2225 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);
2231 INLINE
int Texture::
2232 do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const {
2233 return do_get_expected_mipmap_z_size(cdata, n) * cdata->_num_views;
2239 INLINE
void Texture::
2240 do_clear_ram_image(CData *cdata) {
2241 cdata->_ram_image_compression = CM_off;
2242 cdata->_ram_images.clear();
2248 INLINE AutoTextureScale Texture::
2249 do_get_auto_texture_scale(
const CData *cdata)
const {
2250 if (cdata->_auto_texture_scale == ATS_unspecified) {
2253 return cdata->_auto_texture_scale;
2262 INLINE
void Texture::
2263 store_unscaled_byte(
unsigned char *&p,
int value) {
2264 (*p++) = (uchar)value;
2272 INLINE
void Texture::
2273 store_unscaled_short(
unsigned char *&p,
int value) {
2278 v.us = (ushort)value;
2289 INLINE
void Texture::
2290 store_scaled_byte(
unsigned char *&p,
int value,
double scale) {
2291 store_unscaled_byte(p, (
int)(value * scale));
2300 INLINE
void Texture::
2301 store_scaled_short(
unsigned char *&p,
int value,
double scale) {
2302 store_unscaled_short(p, (
int)(value * scale));
2310 INLINE
double Texture::
2311 get_unsigned_byte(
const unsigned char *&p) {
2312 return (
double)(*p++) / 255.0;
2320 INLINE
double Texture::
2321 get_unsigned_short(
const unsigned char *&p) {
2328 return (
double)v.us / 65535.0;
2336 INLINE
double Texture::
2337 get_unsigned_int(
const unsigned char *&p) {
2346 return (
double)v.ui / 4294967295.0;
2354 INLINE
double Texture::
2355 get_unsigned_int_24(
const unsigned char *&p) {
2364 return (
double)(v.ui & 0xffffff) / (
double)0xffffff;
2372 INLINE
double Texture::
2373 get_float(
const unsigned char *&p) {
2374 double v = *((
float *)p);
2384 INLINE
double Texture::
2385 get_half_float(
const unsigned char *&p) {
2390 uint16_t in = *(uint16_t *)p;
2392 uint32_t t1 = in & 0x7fff;
2393 uint32_t t2 = in & 0x8000;
2394 uint32_t t3 = in & 0x7c00;
2399 t1 = (t3 == 0 ? 0 : t1);
2413 INLINE
bool Texture::
2414 is_txo_filename(
const Filename &fullpath) {
2417 if (extension ==
"pz" || extension ==
"gz") {
2421 return (extension ==
"txo");
2428 INLINE
bool Texture::
2429 is_dds_filename(
const Filename &fullpath) {
2432 if (extension ==
"pz" || extension ==
"gz") {
2436 return (
downcase(extension) ==
"dds");
2443 INLINE
bool Texture::
2444 is_ktx_filename(
const Filename &fullpath) {
2447 if (extension ==
"pz" || extension ==
"gz") {
2451 return (
downcase(extension) ==
"ktx");
2457 INLINE
void Texture::CData::
2458 inc_properties_modified() {
2459 ++_properties_modified;
2465 INLINE
void Texture::CData::
2466 inc_image_modified() {
2473 INLINE
void Texture::CData::
2474 inc_simple_image_modified() {
2475 ++_simple_image_modified;
2481 INLINE Texture::RamImage::
2484 _pointer_image(nullptr)
CPTA_uchar get_ram_image()
Returns the system-RAM image data associated with the texture.
set_z_size
Changes the z size indicated for the texture.
set_fullpath
Sets the full pathname to the file that contains the image's contents, as found along the search path...
bool has_auto_texture_scale() const
Returns true if set_auto_texture_scale() has been set to something other than ATS_unspecified for thi...
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.
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...
set_num_views
Sets the number of "views" within a texture.
int get_pad_y_size() const
Returns size of the pad region.
get_effective_minfilter
Returns the filter mode of the texture for minification, with special treatment for FT_default.
set_filename
Sets the name of the file that contains the image's contents.
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.
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...
set_loaded_from_txo
Sets the flag that indicates the texture has been loaded from a txo file.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
void setup_cube_map_array(int num_cube_maps)
Sets the texture as cube map array with N cube maps.
PT(Texture) Texture
Returns a new copy of the same Texture.
bool might_have_ram_image() const
Returns true if the texture's image contents are currently available in main RAM, or there is reason ...
set_auto_texture_scale
Specifies the power-of-2 texture-scaling mode that will be applied to this particular texture when it...
void clear_image()
Clears the texture data without changing its format or resolution.
set_match_framebuffer_format
Sets the special flag that, if true, indicates to the GSG that the Texture's format should be chosen ...
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...
set_magfilter
Sets the filtering method that should be used when viewing the texture up close.
set_clear_color
Sets the color that will be used to fill the texture image in absence of any image data.
Specifies parameters that may be passed to the loader.
PTA_uchar make_ram_image()
Discards the current system-RAM image for the texture, if any, and allocates a new buffer of the appr...
bool rescale_texture()
This method is similar to consider_rescale(), but instead of scaling a separate PNMImage,...
set_wrap_v
This setting determines what happens when the texture is sampled with a V value outside the range 0....
CPTA_uchar get_uncompressed_ram_image()
Returns the system-RAM image associated with the texture, in an uncompressed form if at all possible.
std::string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
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...
bool has_ram_mipmap_image(int n) const
Returns true if the Texture has the nth mipmap level available in system memory, false otherwise.
bool store(PNMImage &pnmimage) const
Saves the texture to the indicated PNMImage, but does not write it to disk.
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.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.
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_alpha_fullpath
Sets the full pathname to the file that contains the image's alpha channel contents,...
set_wrap_w
The W wrap direction is only used for 3-d textures.
PTA_uchar modify_ram_mipmap_image(int n)
Returns a modifiable pointer to the system-RAM image for the nth mipmap level.
bool has_ram_image() const
Returns true if the Texture has its image contents available in main RAM, false if it exists only in ...
void setup_cube_map()
Sets the texture as an empty cube map texture with no dimensions.
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.
int get_pad_x_size() const
Returns size of the pad region.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
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,...
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.
int get_z_size() const
Returns the depth of the texture image that is contributing to the TexturePeeker's information.
set_border_color
Specifies the solid color of the texture's border.
set_render_to_texture
Sets a flag on the texture that indicates whether the texture is intended to be used as a direct-rend...
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.
static AutoTextureScale get_textures_power_2()
This flag returns ATS_none, ATS_up, or ATS_down and controls the scaling of textures in general.
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,...
bool uses_mipmaps() const
Returns true if the minfilter settings on this texture indicate the use of mipmapping,...
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.
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...
void clear_simple_ram_image()
Discards the current "simple" image.
The name of a file, such as a texture file or an Egg file.
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
set_keep_ram_image
Sets the flag that indicates whether this Texture is eligible to have its main RAM copy of the textur...
void set_pad_size(int x=0, int y=0, int z=0)
Sets the size of the pad region.
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_format
Changes the format value for the texture components.
set_minfilter
Sets the filtering method that should be used when viewing the texture from a distance.
void clear_ram_mipmap_images()
Discards the current system-RAM image for all mipmap levels, except level 0 (the base image).
set_anisotropic_degree
Specifies the level of anisotropic filtering to apply to the texture.
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.
int get_pad_z_size() const
Returns size of the pad region.
set_y_size
Changes the y size indicated for the texture.
set_post_load_store_cache
Sets the post_load_store_cache flag.
void setup_1d_texture()
Sets the texture as an empty 1-d texture with no dimensions.
set_x_size
Changes the x size indicated for the texture.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
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,...
set_wrap_u
This setting determines what happens when the texture is sampled with a U value outside the range 0....
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,...
std::string get_extension() const
Returns the file extension.
void clear_ram_image()
Discards the current system-RAM image.
get_num_views
Returns the number of "views" in the texture.
Represents a set of settings that indicate how a texture is sampled.
bool uncompress_ram_image()
Attempts to uncompress the texture's RAM image internally.
set_default_sampler
This sets the default sampler state for this texture, containing the wrap and filter properties speci...
bool has_all_ram_mipmap_images() const
Returns true if all expected mipmap levels have been defined and exist in the system RAM,...
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.
set_component_type
Changes the data value for the texture components.
bool load(const PNMImage &pnmimage, const LoaderOptions &options=LoaderOptions())
Replaces the texture with the indicated image.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
set_compression
Requests that this particular Texture be compressed when it is loaded into texture memory.
LVecBase2 get_tex_scale() const
Returns a scale pair that is suitable for applying to geometry via NodePath::set_tex_scale(),...
void generate_ram_mipmap_images()
Automatically fills in the n mipmap levels of the Texture, based on the texture's source image.
set_quality_level
Sets a hint to the renderer about the desired performance / quality tradeoff for this particular text...
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.
set_loaded_from_image
Sets the flag that indicates the texture has been loaded from a disk file or PNMImage.
set_alpha_filename
Sets the name of the file that contains the image's alpha channel contents.
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.
void set_simple_ram_image(CPTA_uchar image, int x_size, int y_size)
Replaces the internal "simple" texture image.
static bool has_textures_power_2()
If true, then get_textures_power_2 has been set using set_textures_power_2.
This is a sequence number that increments monotonically.
PTA_uchar modify_ram_image()
Returns a modifiable pointer to the system-RAM image.
bool has_compression() const
Returns true if the texture indicates it wants to be compressed, either with CM_on or higher,...
vector_uchar get_clear_data() const
Returns the raw image data for a single pixel if it were set to the clear color.
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.
bool reload()
Re-reads the Texture from its disk file.
bool write(const Filename &fullpath)
Writes the texture to the named filename.
Similar to PointerToArray, except that its contents may not be modified.
bool has_uncompressed_ram_image() const
Returns true if the Texture has its image contents available in main RAM and is uncompressed,...