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);
195 setup_texture(TT_cube_map_array, size, size, num_cube_maps * 6, component_type, format);
208 GeomEnums::UsageHint usage) {
209 setup_texture(TT_buffer_texture, size, 1, 1, component_type, format);
211 cdata->_usage_hint = usage;
228 do_clear_ram_image(cdata);
229 do_clear_simple_ram_image(cdata);
230 cdata->inc_image_modified();
231 cdata->inc_simple_image_modified();
237 INLINE
bool Texture::
238 has_clear_color()
const {
239 CDReader cdata(_cycler);
240 return cdata->_has_clear_color;
246 INLINE LColor Texture::
247 get_clear_color()
const {
248 CDReader cdata(_cycler);
249 return cdata->_clear_color;
263 CDWriter cdata(_cycler,
true);
264 cdata->_clear_color =
color;
265 cdata->_has_clear_color =
true;
272 INLINE
void Texture::
273 clear_clear_color() {
274 CDWriter cdata(_cycler,
true);
275 cdata->_has_clear_color =
true;
285 vector_uchar data(16);
286 data.resize(do_get_clear_data(cdata, &data[0]));
298 return do_write(cdata, fullpath, 0, 0,
false,
false);
344 bool write_pages,
bool write_mipmaps) {
346 return do_write(cdata, fullpath, z, n, write_pages, write_mipmaps);
356 cdata->inc_properties_modified();
357 cdata->inc_image_modified();
358 if (do_load_one(cdata, pnmimage, get_name(), 0, 0, options)) {
359 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
360 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
372 cdata->inc_properties_modified();
373 cdata->inc_image_modified();
374 if (do_load_one(cdata, pnmimage, get_name(), z, n, options)) {
387 cdata->inc_properties_modified();
388 cdata->inc_image_modified();
389 if (do_load_one(cdata, pfm, get_name(), 0, 0, options)) {
390 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
391 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
403 cdata->inc_properties_modified();
404 cdata->inc_image_modified();
405 if (do_load_one(cdata, pfm, get_name(), z, n, options)) {
421 return do_load_sub_image(cdata, image, x, y, z, n);
430 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, 0, 0);
439 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, z, n);
448 return ((
Texture *)
this)->do_store_one(cdata, pfm, 0, 0);
457 return ((
Texture *)
this)->do_store_one(cdata, pfm, z, n);
470 return do_reload(cdata);
477 INLINE
bool Texture::
478 has_filename()
const {
479 CDReader cdata(_cycler);
480 return !cdata->_filename.empty();
488 get_filename()
const {
489 CDReader cdata(_cycler);
490 return cdata->_filename;
497 INLINE
bool Texture::
498 has_alpha_filename()
const {
499 CDReader cdata(_cycler);
500 return !cdata->_alpha_filename.empty();
509 get_alpha_filename()
const {
510 CDReader cdata(_cycler);
511 return cdata->_alpha_filename;
518 INLINE
bool Texture::
519 has_fullpath()
const {
520 CDReader cdata(_cycler);
521 return !cdata->_fullpath.empty();
529 get_fullpath()
const {
530 CDReader cdata(_cycler);
531 return cdata->_fullpath;
538 INLINE
bool Texture::
539 has_alpha_fullpath()
const {
540 CDReader cdata(_cycler);
541 return !cdata->_alpha_fullpath.empty();
550 get_alpha_fullpath()
const {
551 CDReader cdata(_cycler);
552 return cdata->_alpha_fullpath;
561 CDReader cdata(_cycler);
562 return cdata->_x_size;
571 CDReader cdata(_cycler);
572 return cdata->_y_size;
581 CDReader cdata(_cycler);
582 return cdata->_z_size;
595 get_num_views()
const {
596 CDReader cdata(_cycler);
597 return cdata->_num_views;
608 get_num_pages()
const {
618 return cdata->_pad_x_size;
627 return cdata->_pad_y_size;
636 return cdata->_pad_z_size;
653 if (cdata->_pad_x_size == 0 || cdata->_pad_y_size == 0 ||
654 cdata->_x_size == 0 || cdata->_y_size == 0) {
655 LVecBase2(1.0f, 1.0f);
657 return LVecBase2((PN_stdfloat)(cdata->_x_size - cdata->_pad_x_size) / (PN_stdfloat)cdata->_x_size,
658 (PN_stdfloat)(cdata->_y_size - cdata->_pad_y_size) / (PN_stdfloat)cdata->_y_size);
675 do_set_pad_size(cdata, x, y, z);
684 get_orig_file_x_size()
const {
685 CDReader cdata(_cycler);
686 return cdata->_orig_file_x_size;
695 get_orig_file_y_size()
const {
696 CDReader cdata(_cycler);
697 return cdata->_orig_file_y_size;
706 get_orig_file_z_size()
const {
709 CDReader cdata(_cycler);
710 return cdata->_z_size;
719 get_num_components()
const {
720 CDReader cdata(_cycler);
721 return cdata->_num_components;
729 get_component_width()
const {
730 CDReader cdata(_cycler);
731 return cdata->_component_width;
737 INLINE Texture::TextureType Texture::
738 get_texture_type()
const {
739 CDReader cdata(_cycler);
740 return cdata->_texture_type;
747 INLINE Texture::Format Texture::
749 CDReader cdata(_cycler);
750 return cdata->_format;
756 INLINE Texture::ComponentType Texture::
757 get_component_type()
const {
758 CDReader cdata(_cycler);
759 return cdata->_component_type;
766 INLINE GeomEnums::UsageHint Texture::
767 get_usage_hint()
const {
768 CDReader cdata(_cycler);
769 return cdata->_usage_hint;
782 CDWriter cdata(_cycler,
true);
783 do_set_wrap_u(cdata, wrap);
796 CDWriter cdata(_cycler,
true);
797 do_set_wrap_v(cdata, wrap);
808 CDWriter cdata(_cycler,
true);
809 do_set_wrap_w(cdata, wrap);
821 CDWriter cdata(_cycler,
true);
822 do_set_minfilter(cdata, filter);
834 CDWriter cdata(_cycler,
true);
835 do_set_magfilter(cdata, filter);
852 CDWriter cdata(_cycler,
true);
853 do_set_anisotropic_degree(cdata, anisotropic_degree);
866 CDWriter cdata(_cycler,
true);
867 do_set_border_color(cdata,
color);
886 CDWriter cdata(_cycler,
true);
887 do_set_compression(cdata, compression);
905 CDWriter cdata(_cycler,
false);
906 cdata->_render_to_texture = render_to_texture;
915 get_default_sampler()
const {
916 CDReader cdata(_cycler);
917 return cdata->_default_sampler;
933 CDWriter cdata(_cycler,
true);
934 cdata->_default_sampler = sampler;
935 cdata->inc_properties_modified();
944 INLINE SamplerState::WrapMode Texture::
946 CDReader cdata(_cycler);
947 return cdata->_default_sampler.get_wrap_u();
956 INLINE SamplerState::WrapMode Texture::
958 CDReader cdata(_cycler);
959 return cdata->_default_sampler.get_wrap_v();
969 INLINE SamplerState::WrapMode Texture::
971 CDReader cdata(_cycler);
972 return cdata->_default_sampler.get_wrap_w();
983 INLINE SamplerState::FilterType Texture::
984 get_minfilter()
const {
985 CDReader cdata(_cycler);
986 return cdata->_default_sampler.get_minfilter();
997 INLINE SamplerState::FilterType Texture::
998 get_magfilter()
const {
999 CDReader cdata(_cycler);
1000 return cdata->_default_sampler.get_magfilter();
1011 SamplerState::FilterType Texture::
1012 get_effective_minfilter()
const {
1013 CDReader cdata(_cycler);
1014 return cdata->_default_sampler.get_effective_minfilter();
1025 SamplerState::FilterType Texture::
1026 get_effective_magfilter()
const {
1027 CDReader cdata(_cycler);
1028 return cdata->_default_sampler.get_effective_magfilter();
1039 INLINE
int Texture::
1040 get_anisotropic_degree()
const {
1041 CDReader cdata(_cycler);
1042 return cdata->_default_sampler.get_anisotropic_degree();
1053 INLINE
int Texture::
1054 get_effective_anisotropic_degree()
const {
1055 CDReader cdata(_cycler);
1056 return cdata->_default_sampler.get_effective_anisotropic_degree();
1067 INLINE LColor Texture::
1068 get_border_color()
const {
1069 CDReader cdata(_cycler);
1070 return cdata->_default_sampler.get_border_color();
1082 INLINE Texture::CompressionMode Texture::
1083 get_compression()
const {
1084 CDReader cdata(_cycler);
1085 return cdata->_compression;
1100 return do_has_compression(cdata);
1112 INLINE
bool Texture::
1113 get_render_to_texture()
const {
1114 CDReader cdata(_cycler);
1115 return cdata->_render_to_texture;
1135 CDWriter cdata(_cycler,
true);
1136 do_set_quality_level(cdata, quality_level);
1143 INLINE Texture::QualityLevel Texture::
1144 get_quality_level()
const {
1145 CDReader cdata(_cycler);
1146 return cdata->_quality_level;
1154 INLINE Texture::QualityLevel Texture::
1155 get_effective_quality_level()
const {
1156 CDReader cdata(_cycler);
1157 if (cdata->_quality_level == QL_default) {
1158 return texture_quality_level;
1160 return cdata->_quality_level;
1170 INLINE
int Texture::
1171 get_expected_num_mipmap_levels()
const {
1172 CDReader cdata(_cycler);
1173 return do_get_expected_num_mipmap_levels(cdata);
1183 return do_get_expected_mipmap_x_size(cdata, n);
1193 return do_get_expected_mipmap_y_size(cdata, n);
1203 return do_get_expected_mipmap_z_size(cdata, n);
1215 return do_get_expected_mipmap_num_pages(cdata, n);
1240 return do_has_ram_image(cdata);
1250 return do_has_uncompressed_ram_image(cdata);
1262 return (do_has_ram_image(cdata) || !cdata->_fullpath.empty());
1269 INLINE
size_t Texture::
1270 get_ram_image_size()
const {
1271 CDReader cdata(_cycler);
1272 return do_get_ram_image_size(cdata);
1280 INLINE
size_t Texture::
1281 get_ram_view_size()
const {
1282 CDReader cdata(_cycler);
1283 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1284 return do_get_expected_ram_view_size(cdata);
1286 return cdata->_z_size * cdata->_ram_images[0]._page_size;
1299 INLINE
size_t Texture::
1300 get_ram_page_size()
const {
1301 CDReader cdata(_cycler);
1302 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1303 return do_get_expected_ram_page_size(cdata);
1305 return cdata->_ram_images[0]._page_size;
1313 INLINE
size_t Texture::
1314 get_expected_ram_image_size()
const {
1315 CDReader cdata(_cycler);
1316 return do_get_expected_ram_image_size(cdata);
1324 INLINE
size_t Texture::
1325 get_expected_ram_page_size()
const {
1326 CDReader cdata(_cycler);
1327 return do_get_expected_ram_page_size(cdata);
1353 CDWriter cdata(_cycler, unlocked_ensure_ram_image(
true));
1354 return do_get_ram_image(cdata);
1364 INLINE Texture::CompressionMode Texture::
1365 get_ram_image_compression()
const {
1366 CDReader cdata(_cycler);
1367 return cdata->_ram_image_compression;
1380 cdata->inc_image_modified();
1381 return do_modify_ram_image(cdata);
1401 return do_get_uncompressed_ram_image(cdata);
1413 cdata->inc_image_modified();
1414 return do_make_ram_image(cdata);
1428 do_set_ram_image(cdata, image, compression, page_size);
1437 do_clear_ram_image(cdata);
1452 CDWriter cdata(_cycler,
true);
1453 cdata->_keep_ram_image = keep_ram_image;
1476 Texture::QualityLevel quality_level,
1479 if (do_compress_ram_image(cdata, compression, quality_level, gsg)) {
1480 cdata->inc_image_modified();
1496 if (do_uncompress_ram_image(cdata)) {
1497 cdata->inc_image_modified();
1510 INLINE
int Texture::
1511 get_num_ram_mipmap_images()
const {
1512 CDReader cdata(_cycler);
1513 return cdata->_ram_images.size();
1526 return do_has_ram_mipmap_image(cdata, n);
1536 return do_has_all_ram_mipmap_images(cdata);
1546 if (n >= 0 && n < (
int)cdata->_ram_images.size()) {
1547 if (cdata->_ram_images[n]._pointer_image ==
nullptr) {
1548 return cdata->_ram_images[n]._image.size();
1551 return do_get_ram_mipmap_page_size(cdata, n) *
1552 do_get_expected_mipmap_z_size(cdata, n) *
1574 return do_get_ram_mipmap_page_size(cdata, n) * do_get_expected_mipmap_z_size(cdata, n);
1589 return do_get_ram_mipmap_page_size(cdata, n);
1599 return do_get_expected_ram_mipmap_image_size(cdata, n);
1611 return do_get_expected_ram_mipmap_view_size(cdata, n);
1622 return do_get_expected_ram_mipmap_page_size(cdata, n);
1635 cdata->inc_image_modified();
1636 return do_modify_ram_mipmap_image(cdata, n);
1648 cdata->inc_image_modified();
1649 return do_make_ram_mipmap_image(cdata, n);
1662 do_set_ram_mipmap_image(cdata, n, image, page_size);
1672 cdata->inc_image_modified();
1673 do_clear_ram_mipmap_images(cdata);
1692 cdata->inc_image_modified();
1693 do_generate_ram_mipmap_images(cdata,
true);
1699 INLINE
int Texture::
1700 get_simple_x_size()
const {
1701 CDReader cdata(_cycler);
1702 return cdata->_simple_x_size;
1708 INLINE
int Texture::
1709 get_simple_y_size()
const {
1710 CDReader cdata(_cycler);
1711 return cdata->_simple_y_size;
1717 INLINE
bool Texture::
1718 has_simple_ram_image()
const {
1719 CDReader cdata(_cycler);
1720 return !cdata->_simple_ram_image._image.empty();
1730 return cdata->_simple_ram_image._image.size();
1746 get_simple_ram_image()
const {
1747 CDReader cdata(_cycler);
1748 return cdata->_simple_ram_image._image;
1768 do_set_simple_ram_image(cdata, image, x_size, y_size);
1777 do_clear_simple_ram_image(cdata);
1785 get_properties_modified()
const {
1786 CDReader cdata(_cycler);
1787 return cdata->_properties_modified;
1795 get_image_modified()
const {
1796 CDReader cdata(_cycler);
1797 return cdata->_image_modified;
1805 get_simple_image_modified()
const {
1806 CDReader cdata(_cycler);
1807 return cdata->_simple_image_modified;
1817 CDWriter cdata(_cycler,
true);
1818 cdata->_auto_texture_scale = scale;
1826 INLINE AutoTextureScale Texture::
1827 get_auto_texture_scale()
const {
1828 CDReader cdata(_cycler);
1829 return do_get_auto_texture_scale(cdata);
1839 return (cdata->_auto_texture_scale != ATS_unspecified);
1849 _textures_power_2 = scale;
1860 if (_textures_power_2 == ATS_unspecified) {
1861 return textures_power_2;
1863 return _textures_power_2;
1874 return (_textures_power_2 != ATS_unspecified);
1888 CDWriter cdata(_cycler,
true);
1889 cdata->_filename = filename;
1895 INLINE
void Texture::
1897 CDWriter cdata(_cycler,
true);
1914 CDWriter cdata(_cycler,
true);
1915 cdata->_alpha_filename = alpha_filename;
1922 INLINE
void Texture::
1923 clear_alpha_filename() {
1924 CDWriter cdata(_cycler,
true);
1925 cdata->_alpha_filename =
Filename();
1935 CDWriter cdata(_cycler,
true);
1936 cdata->_fullpath = fullpath;
1942 INLINE
void Texture::
1944 CDWriter cdata(_cycler,
true);
1955 CDWriter cdata(_cycler,
true);
1956 cdata->_alpha_fullpath = alpha_fullpath;
1963 INLINE
void Texture::
1964 clear_alpha_fullpath() {
1965 CDWriter cdata(_cycler,
true);
1966 cdata->_alpha_fullpath =
Filename();
1975 CDWriter cdata(_cycler,
true);
1976 do_set_x_size(cdata, x_size);
1985 CDWriter cdata(_cycler,
true);
1986 do_set_y_size(cdata, y_size);
1995 CDWriter cdata(_cycler,
true);
1996 do_set_z_size(cdata, z_size);
2012 CDWriter cdata(_cycler,
true);
2013 do_set_num_views(cdata, num_views);
2022 CDWriter cdata(_cycler,
true);
2023 do_set_format(cdata, format);
2032 CDWriter cdata(_cycler,
true);
2033 do_set_component_type(cdata, component_type);
2044 CDWriter cdata(_cycler,
false);
2045 cdata->_loaded_from_image = flag;
2052 INLINE
bool Texture::
2053 get_loaded_from_image()
const {
2054 CDReader cdata(_cycler);
2055 return cdata->_loaded_from_image;
2065 CDWriter cdata(_cycler,
false);
2066 cdata->_loaded_from_txo = flag;
2073 INLINE
bool Texture::
2074 get_loaded_from_txo()
const {
2075 CDReader cdata(_cycler);
2076 return cdata->_loaded_from_txo;
2085 INLINE
bool Texture::
2086 get_match_framebuffer_format()
const {
2087 CDReader cdata(_cycler);
2088 return cdata->_match_framebuffer_format;
2102 CDWriter cdata(_cycler,
true);
2103 cdata->_match_framebuffer_format = flag;
2110 INLINE
bool Texture::
2111 get_post_load_store_cache()
const {
2112 CDReader cdata(_cycler);
2113 return cdata->_post_load_store_cache;
2127 CDWriter cdata(_cycler,
true);
2128 cdata->_post_load_store_cache = flag;
2141 return do_rescale_texture(cdata);
2151 bool for_padding)
const {
2153 return do_adjust_this_size(cdata, x_size, y_size, name, for_padding);
2159 INLINE
size_t Texture::
2160 do_get_ram_image_size(
const CData *cdata)
const {
2161 if (cdata->_ram_images.empty()) {
2164 return cdata->_ram_images[0]._image.size();
2170 INLINE
bool Texture::
2171 do_has_ram_mipmap_image(
const CData *cdata,
int n)
const {
2172 return (n >= 0 && n < (
int)cdata->_ram_images.size() &&
2173 !cdata->_ram_images[n]._image.empty());
2179 INLINE
size_t Texture::
2180 do_get_expected_ram_image_size(
const CData *cdata)
const {
2181 return do_get_expected_ram_view_size(cdata) * (size_t)cdata->_num_views;
2187 INLINE
size_t Texture::
2188 do_get_expected_ram_view_size(
const CData *cdata)
const {
2189 return do_get_expected_ram_page_size(cdata) * (size_t)cdata->_z_size;
2195 INLINE
size_t Texture::
2196 do_get_expected_ram_page_size(
const CData *cdata)
const {
2197 return (
size_t)(cdata->_x_size * cdata->_y_size * cdata->_num_components * cdata->_component_width);
2203 INLINE
size_t Texture::
2204 do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const {
2205 return do_get_expected_ram_mipmap_view_size(cdata, n) * (size_t)cdata->_num_views;
2211 INLINE
size_t Texture::
2212 do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const {
2213 return do_get_expected_ram_mipmap_page_size(cdata, n) * (size_t)do_get_expected_mipmap_z_size(cdata, n);
2219 INLINE
size_t Texture::
2220 do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const {
2221 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);
2227 INLINE
int Texture::
2228 do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const {
2229 return do_get_expected_mipmap_z_size(cdata, n) * cdata->_num_views;
2235 INLINE
void Texture::
2236 do_clear_ram_image(CData *cdata) {
2237 cdata->_ram_image_compression = CM_off;
2238 cdata->_ram_images.clear();
2244 INLINE AutoTextureScale Texture::
2245 do_get_auto_texture_scale(
const CData *cdata)
const {
2246 if (cdata->_auto_texture_scale == ATS_unspecified) {
2249 return cdata->_auto_texture_scale;
2258 INLINE
void Texture::
2259 store_unscaled_byte(
unsigned char *&p,
int value) {
2260 (*p++) = (uchar)value;
2268 INLINE
void Texture::
2269 store_unscaled_short(
unsigned char *&p,
int value) {
2274 v.us = (ushort)value;
2285 INLINE
void Texture::
2286 store_scaled_byte(
unsigned char *&p,
int value,
double scale) {
2287 store_unscaled_byte(p, (
int)(value * scale));
2296 INLINE
void Texture::
2297 store_scaled_short(
unsigned char *&p,
int value,
double scale) {
2298 store_unscaled_short(p, (
int)(value * scale));
2306 INLINE
double Texture::
2307 get_unsigned_byte(
const unsigned char *&p) {
2308 return (
double)(*p++) / 255.0;
2316 INLINE
double Texture::
2317 get_unsigned_short(
const unsigned char *&p) {
2324 return (
double)v.us / 65535.0;
2332 INLINE
double Texture::
2333 get_unsigned_int(
const unsigned char *&p) {
2342 return (
double)v.ui / 4294967295.0;
2350 INLINE
double Texture::
2351 get_unsigned_int_24(
const unsigned char *&p) {
2360 return (
double)(v.ui & 0xffffff) / (
double)0xffffff;
2368 INLINE
double Texture::
2369 get_float(
const unsigned char *&p) {
2370 double v = *((
float *)p);
2380 INLINE
double Texture::
2381 get_half_float(
const unsigned char *&p) {
2386 uint16_t in = *(uint16_t *)p;
2388 uint32_t t1 = in & 0x7fff;
2389 uint32_t t2 = in & 0x8000;
2390 uint32_t t3 = in & 0x7c00;
2395 t1 = (t3 == 0 ? 0 : t1);
2409 INLINE
bool Texture::
2410 is_txo_filename(
const Filename &fullpath) {
2413 if (extension ==
"pz" || extension ==
"gz") {
2417 return (extension ==
"txo");
2424 INLINE
bool Texture::
2425 is_dds_filename(
const Filename &fullpath) {
2428 if (extension ==
"pz" || extension ==
"gz") {
2432 return (
downcase(extension) ==
"dds");
2439 INLINE
bool Texture::
2440 is_ktx_filename(
const Filename &fullpath) {
2443 if (extension ==
"pz" || extension ==
"gz") {
2447 return (
downcase(extension) ==
"ktx");
2453 INLINE
void Texture::CData::
2454 inc_properties_modified() {
2455 ++_properties_modified;
2461 INLINE
void Texture::CData::
2462 inc_image_modified() {
2469 INLINE
void Texture::CData::
2470 inc_simple_image_modified() {
2471 ++_simple_image_modified;
2477 INLINE Texture::RamImage::
2480 _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, it will ask the Texture to rescale its own internal image to a power of 2, according to the config file requirements.
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, as found along the search path.
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, false otherwise.
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, or with a special extension, 2- or 4-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, for mipmap level n.
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(), which will convert texture coordinates on the geometry from the range 0..1 into the appropriate range to render the video part of the texture.
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, false otherwise.