32 PT(
Texture) tex = make_copy_impl();
33 CDWriter cdata_tex(tex->_cycler,
true);
34 cdata_tex->inc_properties_modified();
35 cdata_tex->inc_image_modified();
36 cdata_tex->inc_simple_image_modified();
48 CDWriter cdata(_cycler,
true);
62 setup_texture(Texture::TextureType texture_type,
int x_size,
int y_size,
63 int z_size, Texture::ComponentType component_type,
64 Texture::Format format) {
66 do_setup_texture(cdata, texture_type, x_size, y_size, z_size,
67 component_type, format);
95 setup_texture(TT_1d_texture, x_size, 1, 1, component_type, format);
124 setup_texture(TT_2d_texture, x_size, y_size, 1, component_type, format);
152 ComponentType component_type, Format format) {
153 setup_texture(TT_3d_texture, x_size, y_size, z_size, component_type, format);
182 ComponentType component_type, Format format) {
183 setup_texture(TT_2d_texture_array, x_size, y_size, z_size, component_type, format);
215 setup_texture(TT_cube_map, size, size, 6, component_type, format);
236 do_clear_ram_image(cdata);
237 do_clear_simple_ram_image(cdata);
238 cdata->inc_image_modified();
239 cdata->inc_simple_image_modified();
251 return cdata->_has_clear_color;
263 return cdata->_clear_color;
281 cdata->_clear_color = color;
282 cdata->_has_clear_color =
true;
294 unsigned char data[16];
295 int size = do_get_clear_data(cdata, data);
296 return string((
char *)data, size);
310 return do_write(cdata, fullpath, 0, 0,
false,
false);
371 bool write_pages,
bool write_mipmaps) {
373 return do_write(cdata, fullpath, z, n, write_pages, write_mipmaps);
385 cdata->inc_properties_modified();
386 cdata->inc_image_modified();
387 if (do_load_one(cdata, pnmimage, get_name(), 0, 0, options)) {
388 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
389 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
404 cdata->inc_properties_modified();
405 cdata->inc_image_modified();
406 if (do_load_one(cdata, pnmimage, get_name(), z, n, options)) {
421 cdata->inc_properties_modified();
422 cdata->inc_image_modified();
423 if (do_load_one(cdata, pfm, get_name(), 0, 0, options)) {
424 bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0);
425 consider_auto_process_ram_image(generate_mipmaps ||
uses_mipmaps(),
true);
440 cdata->inc_properties_modified();
441 cdata->inc_image_modified();
442 if (do_load_one(cdata, pfm, get_name(), z, n, options)) {
462 return do_load_sub_image(cdata, image, x, y, z, n);
474 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, 0, 0);
486 return ((
Texture *)
this)->do_store_one(cdata, pnmimage, z, n);
498 return ((
Texture *)
this)->do_store_one(cdata, pfm, 0, 0);
510 return ((
Texture *)
this)->do_store_one(cdata, pfm, z, n);
526 return do_reload(cdata);
538 return !cdata->_filename.empty();
551 return cdata->_filename;
563 return !cdata->_alpha_filename.empty();
577 return cdata->_alpha_filename;
589 return !cdata->_fullpath.empty();
602 return cdata->_fullpath;
614 return !cdata->_alpha_fullpath.empty();
628 return cdata->_alpha_fullpath;
640 return cdata->_x_size;
652 return cdata->_y_size;
665 return cdata->_z_size;
685 return cdata->_num_views;
711 return cdata->_pad_x_size;
722 return cdata->_pad_y_size;
733 return cdata->_pad_z_size;
754 if (cdata->_pad_x_size == 0 || cdata->_pad_y_size == 0 ||
755 cdata->_x_size == 0 || cdata->_y_size == 0) {
758 return LVecBase2((PN_stdfloat)(cdata->_x_size - cdata->_pad_x_size) / (PN_stdfloat)cdata->_x_size,
759 (PN_stdfloat)(cdata->_y_size - cdata->_pad_y_size) / (PN_stdfloat)cdata->_y_size);
781 do_set_pad_size(cdata, x, y, z);
794 return cdata->_orig_file_x_size;
807 return cdata->_orig_file_y_size;
823 return cdata->_z_size;
837 return cdata->_num_components;
850 return cdata->_component_width;
861 return cdata->_texture_type;
874 return cdata->_format;
886 return cdata->_component_type;
904 do_set_wrap_u(cdata, wrap);
922 do_set_wrap_v(cdata, wrap);
937 do_set_wrap_w(cdata, wrap);
953 do_set_minfilter(cdata, filter);
969 do_set_magfilter(cdata, filter);
992 do_set_anisotropic_degree(cdata, anisotropic_degree);
1010 do_set_border_color(cdata, color);
1035 do_set_compression(cdata, compression);
1058 cdata->_render_to_texture = render_to_texture;
1073 return cdata->_default_sampler;
1089 return cdata->_default_sampler.get_wrap_u();
1105 return cdata->_default_sampler.get_wrap_v();
1122 return cdata->_default_sampler.get_wrap_w();
1138 INLINE SamplerState::FilterType
Texture:: 1141 return cdata->_default_sampler.get_minfilter();
1156 INLINE SamplerState::FilterType
Texture:: 1159 return cdata->_default_sampler.get_magfilter();
1177 return cdata->_default_sampler.get_effective_minfilter();
1195 return cdata->_default_sampler.get_effective_magfilter();
1213 return cdata->_default_sampler.get_anisotropic_degree();
1231 return cdata->_default_sampler.get_effective_anisotropic_degree();
1249 return cdata->_default_sampler.get_border_color();
1266 INLINE Texture::CompressionMode
Texture:: 1269 return cdata->_compression;
1289 return do_has_compression(cdata);
1308 return cdata->_render_to_texture;
1335 do_set_quality_level(cdata, quality_level);
1348 return cdata->_quality_level;
1363 if (cdata->_quality_level == QL_default) {
1364 return texture_quality_level;
1366 return cdata->_quality_level;
1382 return do_get_expected_num_mipmap_levels(cdata);
1394 return do_get_expected_mipmap_x_size(cdata, n);
1406 return do_get_expected_mipmap_y_size(cdata, n);
1418 return do_get_expected_mipmap_z_size(cdata, n);
1433 return do_get_expected_mipmap_num_pages(cdata, n);
1467 return do_has_ram_image(cdata);
1480 return do_has_uncompressed_ram_image(cdata);
1496 return (do_has_ram_image(cdata) || !cdata->_fullpath.empty());
1509 return do_get_ram_image_size(cdata);
1523 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1524 return do_get_expected_ram_view_size(cdata);
1526 return cdata->_z_size * cdata->_ram_images[0]._page_size;
1545 if (cdata->_ram_image_compression == CM_off || cdata->_ram_images.empty()) {
1546 return do_get_expected_ram_page_size(cdata);
1548 return cdata->_ram_images[0]._page_size;
1562 return do_get_expected_ram_image_size(cdata);
1576 return do_get_expected_ram_page_size(cdata);
1609 CDWriter cdata(_cycler, unlocked_ensure_ram_image(
true));
1610 return do_get_ram_image(cdata);
1623 INLINE Texture::CompressionMode
Texture:: 1626 return cdata->_ram_image_compression;
1642 cdata->inc_image_modified();
1643 return do_modify_ram_image(cdata);
1668 return do_get_uncompressed_ram_image(cdata);
1683 cdata->inc_image_modified();
1684 return do_make_ram_image(cdata);
1701 do_set_ram_image(cdata, image, compression, page_size);
1712 do_clear_ram_image(cdata);
1733 cdata->_keep_ram_image = keep_ram_image;
1763 Texture::QualityLevel quality_level,
1766 if (do_compress_ram_image(cdata, compression, quality_level, gsg)) {
1767 cdata->inc_image_modified();
1787 if (do_uncompress_ram_image(cdata)) {
1788 cdata->inc_image_modified();
1808 return cdata->_ram_images.size();
1824 return do_has_ram_mipmap_image(cdata, n);
1837 return do_has_all_ram_mipmap_images(cdata);
1850 if (n >= 0 && n < (
int)cdata->_ram_images.size()) {
1851 return cdata->_ram_images[n]._image.size();
1876 return do_get_ram_mipmap_page_size(cdata, n) * do_get_expected_mipmap_z_size(cdata, n);
1895 return do_get_ram_mipmap_page_size(cdata, n);
1908 return do_get_expected_ram_mipmap_image_size(cdata, n);
1923 return do_get_expected_ram_mipmap_view_size(cdata, n);
1937 return do_get_expected_ram_mipmap_page_size(cdata, n);
1953 cdata->inc_image_modified();
1954 return do_modify_ram_mipmap_image(cdata, n);
1969 cdata->inc_image_modified();
1970 return do_make_ram_mipmap_image(cdata, n);
1987 do_set_ram_mipmap_image(cdata, n, image, page_size);
1999 cdata->inc_image_modified();
2000 do_clear_ram_mipmap_images(cdata);
2019 CDWriter cdata(_cycler, unlocked_ensure_ram_image(
false));
2020 cdata->inc_image_modified();
2021 do_generate_ram_mipmap_images(cdata);
2032 return cdata->_simple_x_size;
2043 return cdata->_simple_y_size;
2055 return !cdata->_simple_ram_image._image.empty();
2067 return cdata->_simple_ram_image._image.size();
2090 return cdata->_simple_ram_image._image;
2116 do_set_simple_ram_image(cdata, image, x_size, y_size);
2127 do_clear_simple_ram_image(cdata);
2140 return cdata->_properties_modified;
2153 return cdata->_image_modified;
2166 return cdata->_simple_image_modified;
2179 cdata->_auto_texture_scale = scale;
2192 return do_get_auto_texture_scale(cdata);
2205 return (cdata->_auto_texture_scale != ATS_unspecified);
2219 _textures_power_2 = scale;
2233 if (_textures_power_2 == ATS_unspecified) {
2234 return textures_power_2;
2236 return _textures_power_2;
2250 return (_textures_power_2 != ATS_unspecified);
2269 cdata->_filename = filename;
2303 cdata->_alpha_filename = alpha_filename;
2315 cdata->_alpha_filename =
Filename();
2329 cdata->_fullpath = fullpath;
2356 cdata->_alpha_fullpath = alpha_fullpath;
2368 cdata->_alpha_fullpath =
Filename();
2381 do_set_x_size(cdata, x_size);
2394 do_set_y_size(cdata, y_size);
2407 do_set_z_size(cdata, z_size);
2430 do_set_num_views(cdata, num_views);
2442 do_set_format(cdata, format);
2454 do_set_component_type(cdata, component_type);
2469 cdata->_loaded_from_image =
true;
2482 return cdata->_loaded_from_image;
2496 cdata->_loaded_from_txo =
true;
2508 return cdata->_loaded_from_txo;
2524 return cdata->_match_framebuffer_format;
2544 cdata->_match_framebuffer_format = flag;
2556 return cdata->_post_load_store_cache;
2575 cdata->_post_load_store_cache = flag;
2593 return do_rescale_texture(cdata);
2605 bool for_padding)
const {
2607 return do_adjust_this_size(cdata, x_size, y_size, name, for_padding);
2615 INLINE
size_t Texture::
2616 do_get_ram_image_size(
const CData *cdata)
const {
2617 if (cdata->_ram_images.empty()) {
2620 return cdata->_ram_images[0]._image.size();
2628 INLINE
bool Texture::
2629 do_has_ram_mipmap_image(
const CData *cdata,
int n)
const {
2630 return (n >= 0 && n < (
int)cdata->_ram_images.size() &&
2631 !cdata->_ram_images[n]._image.empty());
2639 INLINE
size_t Texture::
2640 do_get_expected_ram_image_size(
const CData *cdata)
const {
2641 return do_get_expected_ram_view_size(cdata) * (size_t)cdata->_num_views;
2649 INLINE
size_t Texture::
2650 do_get_expected_ram_view_size(
const CData *cdata)
const {
2651 return do_get_expected_ram_page_size(cdata) * (size_t)cdata->_z_size;
2659 INLINE
size_t Texture::
2660 do_get_expected_ram_page_size(
const CData *cdata)
const {
2661 return (
size_t)(cdata->_x_size * cdata->_y_size * cdata->_num_components * cdata->_component_width);
2669 INLINE
size_t Texture::
2670 do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const {
2671 return do_get_expected_ram_mipmap_view_size(cdata, n) * (size_t)cdata->_num_views;
2679 INLINE
size_t Texture::
2680 do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const {
2681 return do_get_expected_ram_mipmap_page_size(cdata, n) * (size_t)do_get_expected_mipmap_z_size(cdata, n);
2689 INLINE
size_t Texture::
2690 do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const {
2691 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);
2699 INLINE
int Texture::
2700 do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const {
2701 return do_get_expected_mipmap_z_size(cdata, n) * cdata->_num_views;
2709 INLINE
void Texture::
2710 do_clear_ram_image(CData *cdata) {
2711 cdata->_ram_image_compression = CM_off;
2712 cdata->_ram_images.clear();
2720 INLINE AutoTextureScale Texture::
2721 do_get_auto_texture_scale(
const CData *cdata)
const {
2722 if (cdata->_auto_texture_scale == ATS_unspecified) {
2725 return cdata->_auto_texture_scale;
2738 INLINE
void Texture::
2739 store_unscaled_byte(
unsigned char *&p,
int value) {
2740 (*p++) = (uchar)value;
2752 INLINE
void Texture::
2753 store_unscaled_short(
unsigned char *&p,
int value) {
2758 v.us = (ushort)value;
2772 INLINE
void Texture::
2773 store_scaled_byte(
unsigned char *&p,
int value,
double scale) {
2774 store_unscaled_byte(p, (
int)(value * scale));
2786 INLINE
void Texture::
2787 store_scaled_short(
unsigned char *&p,
int value,
double scale) {
2788 store_unscaled_short(p, (
int)(value * scale));
2799 INLINE
double Texture::
2800 get_unsigned_byte(
const unsigned char *&p) {
2801 return (
double)(*p++) / 255.0;
2812 INLINE
double Texture::
2813 get_unsigned_short(
const unsigned char *&p) {
2820 return (
double)v.us / 65535.0;
2829 INLINE
bool Texture::
2830 is_txo_filename(
const Filename &fullpath) {
2833 if (extension ==
"pz") {
2837 return (extension ==
"txo");
2846 INLINE
bool Texture::
2847 is_dds_filename(
const Filename &fullpath) {
2850 if (extension ==
"pz") {
2854 return (downcase(extension) ==
"dds");
2862 INLINE
void Texture::CData::
2863 inc_properties_modified() {
2864 ++_properties_modified;
2872 INLINE
void Texture::CData::
2873 inc_image_modified() {
2882 INLINE
void Texture::CData::
2883 inc_simple_image_modified() {
2884 ++_simple_image_modified;
2892 INLINE Texture::RamImage::
2895 _pointer_image(NULL)
CPTA_uchar get_ram_image()
Returns the system-RAM image data associated with the texture.
int get_num_pages() const
Returns the total number of pages in the texture.
int get_num_ram_mipmap_images() const
Returns the maximum number of mipmap level images available in system memory.
Format get_format() const
Returns the format of the texture, which represents both the semantic meaning of the texels and...
const Filename & get_fullpath() const
Returns the 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...
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...
int get_pad_y_size() const
Returns size of the pad region.
int get_z_size() const
Returns the depth of the texture image in texels.
LColor get_border_color() const
Returns the solid color of the texture's border.
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 le...
const Filename & get_alpha_filename() const
Returns the alpha_filename that has been set.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
string get_clear_data() const
Returns the raw image data for a single pixel if it were set to the clear color.
CompressionMode get_compression() const
Returns the compression mode requested for this particular texture, or CM_off if the texture is not t...
TextureType get_texture_type() const
Returns the overall interpretation of the texture.
size_t get_ram_image_size() const
Returns the total number of bytes used by the in-memory image, across all pages and views...
int get_anisotropic_degree() const
Returns the degree of anisotropic filtering that should be applied to the texture.
void set_loaded_from_txo()
Sets the flag that indicates the texture has been loaded from a txo file.
bool get_render_to_texture() const
Returns a flag on the texture that indicates whether the texture is intended to be used as a direct-r...
void clear_filename()
Removes the alpha filename, if it was previously set.
bool might_have_ram_image() const
Returns true if the texture's image contents are currently available in main RAM, or there is reason ...
void clear_image()
Clears the texture data without changing its format or resolution.
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...
SamplerState::WrapMode get_wrap_v() const
Returns the wrap mode of the texture in the V direction.
int get_orig_file_y_size() const
Returns the Y size of the original disk image that this Texture was loaded from (if it came from a di...
AutoTextureScale get_auto_texture_scale() const
Returns the power-of-2 texture-scaling mode that will be applied to this particular texture when it i...
Specifies parameters that may be passed to the loader.
void clear_fullpath()
Removes the alpha fullpath, if it was previously set.
PTA_uchar make_ram_image()
Discards the current system-RAM image for the texture, if any, and allocates a new buffer of the appr...
int get_orig_file_z_size() const
Returns the Z size of the original disk image that this Texture was loaded from (if it came from a di...
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.
const SamplerState & get_default_sampler() const
This returns the default sampler state for this texture, containing the wrap and filter properties sp...
CPTA_uchar get_uncompressed_ram_image()
Returns the system-RAM image associated with the texture, in an uncompressed form if at all possible...
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...
void set_format(Format format)
Changes the format value for the texture components.
void set_match_framebuffer_format(bool flag)
Sets the special flag that, if true, indicates to the GSG that the Texture's format should be chosen ...
void set_post_load_store_cache(bool flag)
Sets the post_load_store_cache flag.
SamplerState::FilterType get_magfilter() const
Returns the filter mode of the texture for magnification.
bool has_alpha_filename() const
Returns true if the alpha_filename has been set and is available.
bool has_ram_mipmap_image(int n) const
Returns true if the Texture has the nth mipmap level available in system memory, false otherwise...
void clear_alpha_fullpath()
Removes the alpha fullpath, if it was previously set.
bool store(PNMImage &pnmimage) const
Saves the texture to the indicated PNMImage, but does not write it to disk.
bool has_alpha_fullpath() const
Returns true if the alpha_fullpath has been set and is available.
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.
static bool is_mipmap(FilterType type)
Returns true if the indicated filter type requires the use of mipmaps, or false if it does not...
size_t get_ram_view_size() const
Returns the number of bytes used by the in-memory image per view, or 0 if there is no in-memory image...
const Filename & get_alpha_fullpath() const
Returns the alpha_fullpath that has been set.
void set_magfilter(FilterType filter)
Sets the filtering method that should be used when viewing the texture up close.
int get_component_width() const
Returns the number of bytes stored for each color component of a texel.
PTA_uchar modify_ram_mipmap_image(int n)
Returns a modifiable pointer to the system-RAM image for the nth mipmap level.
bool compress_ram_image(CompressionMode compression=CM_on, QualityLevel quality_level=QL_default, GraphicsStateGuardianBase *gsg=NULL)
Attempts to compress the texture's RAM image internally, to a format supported by the indicated GSG...
string get_extension() const
Returns the file extension.
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.
ComponentType get_component_type() const
Returns the numeric interpretation of each component of the texture.
int get_simple_y_size() const
Returns the height of the "simple" image in texels.
void set_alpha_fullpath(const Filename &alpha_fullpath)
Sets the full pathname to the file that contains the image's alpha channel contents, as found along the search path.
void set_fullpath(const Filename &fullpath)
Sets the full pathname to the file that contains the image's contents, as found along the search path...
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 ...
int get_orig_file_x_size() const
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_view_size(int n) const
Returns the number of bytes used by the in-memory image per view for mipmap level n...
size_t get_ram_page_size() const
Returns the number of bytes used by the in-memory image per page, or 0 if there is no in-memory image...
bool get_match_framebuffer_format() const
Returns true if the special flag was set that indicates to the GSG that the Texture's format should b...
SamplerState::WrapMode get_wrap_u() const
Returns the wrap mode of the texture in the U direction.
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...
CPTA_uchar get_simple_ram_image() const
Returns the image data associated with the "simple" texture image.
size_t get_expected_ram_image_size() const
Returns the number of bytes that *ought* to be used by the in-memory image, based on the texture para...
QualityLevel get_effective_quality_level() const
Returns the current quality_level hint, or the global default quality_level if this texture doesn't s...
bool uses_mipmaps() const
Returns true if the minfilter settings on this texture indicate the use of mipmapping, false otherwise.
UpdateSeq get_image_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture image data (i...
bool has_filename() const
Returns true if the filename has been set and is available.
UpdateSeq get_properties_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture properties (u...
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.
bool get_loaded_from_txo() const
Returns the flag that indicates the texture has been loaded from a txo file.
void set_pad_size(int x=0, int y=0, int z=0)
Sets the size of the pad region.
void set_wrap_v(WrapMode wrap)
This setting determines what happens when the texture is sampled with a V 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...
void set_keep_ram_image(bool keep_ram_image)
Sets the flag that indicates whether this Texture is eligible to have its main RAM copy of the textur...
void clear_ram_mipmap_images()
Discards the current system-RAM image for all mipmap levels, except level 0 (the base image)...
bool has_simple_ram_image() const
Returns true if the Texture has a "simple" image available in main RAM.
int get_effective_anisotropic_degree() const
Returns the degree of anisotropic filtering that should be applied to the texture.
int get_pad_z_size() const
Returns size of the pad region.
LColor get_clear_color() const
Returns the color that was previously set using set_clear_color.
void set_alpha_filename(const Filename &alpha_filename)
Sets the name of the file that contains the image's alpha channel contents.
This is the base class for all two-component vectors and points.
void set_quality_level(QualityLevel quality_level)
Sets a hint to the renderer about the desired performance / quality tradeoff for this particular text...
int get_expected_num_mipmap_levels() const
Returns the number of mipmap levels that should be defined for this texture, given the texture's size...
QualityLevel get_quality_level() const
Returns the current quality_level hint.
void set_render_to_texture(bool render_to_texture)
Sets a flag on the texture that indicates whether the texture is intended to be used as a direct-rend...
void setup_1d_texture()
Sets the texture as an empty 1-d texture with no dimensions.
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...
bool has_clear_color() const
Returns true if a color was previously set using set_clear_color.
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
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.
void set_compression(CompressionMode compression)
Requests that this particular Texture be compressed when it is loaded into texture memory...
void clear_ram_image()
Discards the current system-RAM image.
SamplerState::FilterType get_effective_magfilter() const
Returns the filter mode of the texture for magnification, with special treatment for FT_default...
void set_loaded_from_image()
Sets the flag that indicates the texture has been loaded from a disk file or PNMImage.
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.
void set_num_views(int num_views)
Sets the number of "views" within a texture.
This is the base class for all three-component vectors and points.
bool has_all_ram_mipmap_images() const
Returns true if all expected mipmap levels have been defined and exist in the system RAM...
CompressionMode get_ram_image_compression() const
Returns the compression mode in which the ram image is already stored pre-compressed.
void set_anisotropic_degree(int anisotropic_degree)
Specifies the level of anisotropic filtering to apply to 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.
void set_auto_texture_scale(AutoTextureScale scale)
Specifies the power-of-2 texture-scaling mode that will be applied to this particular texture when it...
void set_wrap_u(WrapMode wrap)
This setting determines what happens when the texture is sampled with a U value outside the range 0...
void set_component_type(ComponentType 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...
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 clear_alpha_filename()
Removes the alpha filename, if it was previously set.
void generate_ram_mipmap_images()
Automatically fills in the n mipmap levels of the Texture, based on the texture's source image...
void set_y_size(int y_size)
Changes the y size indicated for the texture.
int get_y_size() const
Returns the height of the texture image in texels.
UpdateSeq get_simple_image_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture's "simple" im...
SamplerState::FilterType get_effective_minfilter() const
Returns the filter mode of the texture for minification, with special treatment for FT_default...
bool get_loaded_from_image() const
Returns the flag that indicates the texture has been loaded from a disk file or PNMImage.
void set_minfilter(FilterType filter)
Sets the filtering method that should be used when viewing the texture from a distance.
int get_num_views() const
Returns the number of "views" in the texture.
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...
bool has_fullpath() const
Returns true if the fullpath has been set and is available.
void set_simple_ram_image(CPTA_uchar image, int x_size, int y_size)
Replaces the internal "simple" texture image.
int get_num_components() const
Returns the number of color components for each texel of the texture image.
void set_clear_color(const LColor &color)
Sets the color that will be used to fill the texture image in absence of any image data...
static bool has_textures_power_2()
If true, then get_textures_power_2 has been set using set_textures_power_2.
void set_border_color(const LColor &color)
Specifies the solid color of the texture's border.
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...
void set_z_size(int z_size)
Changes the z size indicated for the texture.
void set_x_size(int x_size)
Changes the x size indicated for the texture.
int get_simple_x_size() const
Returns the width of the "simple" image in texels.
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 adjust_this_size(int &x_size, int &y_size, const string &name, bool for_padding) const
Works like adjust_size, but also considers the texture class.
void set_wrap_w(WrapMode wrap)
The W wrap direction is only used for 3-d textures.
SamplerState::FilterType get_minfilter() const
Returns the filter mode of the texture for minification.
SamplerState::WrapMode get_wrap_w() const
Returns the wrap mode of the texture in the W direction.
bool reload()
Re-reads the Texture from its disk file.
size_t get_expected_ram_page_size() const
Returns the number of bytes that should be used per each Z page of the 3-d texture.
void set_filename(const Filename &filename)
Sets the name of the file that contains the image's contents.
bool get_post_load_store_cache() const
Returns the setting of the post_load_store_cache flag.
bool write(const Filename &fullpath)
Writes the texture to the named filename.
int get_x_size() const
Returns the width of the texture image in texels.
const Filename & get_filename() const
Returns the filename that has been set.
bool has_uncompressed_ram_image() const
Returns true if the Texture has its image contents available in main RAM and is uncompressed, false otherwise.