73 typedef PT(
Texture) MakeTextureFunc();
128 F_luminance_alphamask,
176 enum DeprecatedFilterType {
177 FT_nearest = SamplerState::FT_nearest,
178 FT_linear = SamplerState::FT_linear,
179 FT_nearest_mipmap_nearest = SamplerState::FT_nearest_mipmap_nearest,
180 FT_linear_mipmap_nearest = SamplerState::FT_linear_mipmap_nearest,
181 FT_nearest_mipmap_linear = SamplerState::FT_nearest_mipmap_linear,
182 FT_linear_mipmap_linear = SamplerState::FT_linear_mipmap_linear,
183 FT_shadow = SamplerState::FT_shadow,
184 FT_default = SamplerState::FT_default,
185 FT_invalid = SamplerState::FT_invalid
187 typedef SamplerState::FilterType FilterType;
190 enum DeprecatedWrapMode {
191 WM_clamp = SamplerState::WM_clamp,
192 WM_repeat = SamplerState::WM_repeat,
193 WM_mirror = SamplerState::WM_mirror,
194 WM_mirror_once = SamplerState::WM_mirror_once,
195 WM_border_color = SamplerState::WM_border_color,
196 WM_invalid = SamplerState::WM_invalid
198 typedef SamplerState::WrapMode WrapMode;
200 enum CompressionMode {
233 explicit Texture(
const std::string &name = std::string());
237 void operator = (
const Texture ©);
242 INLINE PT(
Texture) make_copy()
const;
245 INLINE
void setup_texture(TextureType texture_type,
246 int x_size,
int y_size,
int z_size,
247 ComponentType component_type, Format format);
248 INLINE
void setup_1d_texture();
249 INLINE
void setup_1d_texture(
int x_size,
250 ComponentType component_type, Format format);
251 INLINE
void setup_2d_texture();
252 INLINE
void setup_2d_texture(
int x_size,
int y_size,
253 ComponentType component_type, Format format);
254 INLINE
void setup_3d_texture(
int z_size = 1);
255 INLINE
void setup_3d_texture(
int x_size,
int y_size,
int z_size,
256 ComponentType component_type, Format format);
257 INLINE
void setup_cube_map();
258 INLINE
void setup_cube_map(
int size,
259 ComponentType component_type, Format format);
260 INLINE
void setup_2d_texture_array(
int z_size = 1);
261 INLINE
void setup_2d_texture_array(
int x_size,
int y_size,
int z_size,
262 ComponentType component_type, Format format);
263 INLINE
void setup_cube_map_array(
int num_cube_maps);
264 INLINE
void setup_cube_map_array(
int size,
int num_cube_maps,
265 ComponentType component_type, Format format);
266 INLINE
void setup_buffer_texture(
int size, ComponentType component_type,
267 Format format, GeomEnums::UsageHint usage);
268 void generate_normalization_cube_map(
int size);
269 void generate_alpha_scale_map();
271 INLINE
void clear_image();
272 INLINE
bool has_clear_color()
const;
273 INLINE LColor get_clear_color()
const;
274 INLINE
void set_clear_color(
const LColor &color);
275 INLINE
void clear_clear_color();
276 INLINE vector_uchar get_clear_data()
const;
277 MAKE_PROPERTY2(clear_color, has_clear_color, get_clear_color,
278 set_clear_color, clear_clear_color);
281 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
282 int primary_file_num_channels,
int alpha_file_channel,
284 BLOCKING
bool read(
const Filename &fullpath,
int z,
int n,
285 bool read_pages,
bool read_mipmaps,
287 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
288 int primary_file_num_channels,
int alpha_file_channel,
289 int z,
int n,
bool read_pages,
bool read_mipmaps,
293 BLOCKING INLINE
bool write(
const Filename &fullpath);
294 BLOCKING INLINE
bool write(
const Filename &fullpath,
int z,
int n,
295 bool write_pages,
bool write_mipmaps);
297 BLOCKING
bool read_txo(std::istream &in,
const std::string &filename =
"");
298 BLOCKING
static PT(
Texture) make_from_txo(std::istream &in,
const std::string &filename =
"");
299 BLOCKING
bool write_txo(std::ostream &out,
const std::string &filename =
"")
const;
300 BLOCKING
bool read_dds(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
301 BLOCKING
bool read_ktx(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
307 BLOCKING INLINE
bool load_sub_image(
const PNMImage &pnmimage,
int x,
int y,
int z=0,
int n=0);
308 BLOCKING INLINE
bool store(
PNMImage &pnmimage)
const;
309 BLOCKING INLINE
bool store(
PNMImage &pnmimage,
int z,
int n)
const;
310 BLOCKING INLINE
bool store(
PfmFile &pfm)
const;
311 BLOCKING INLINE
bool store(
PfmFile &pfm,
int z,
int n)
const;
313 BLOCKING INLINE
bool reload();
316 INLINE
bool has_filename()
const;
317 INLINE
const Filename &get_filename()
const;
318 INLINE
void set_filename(
const Filename &filename);
319 INLINE
void clear_filename();
320 MAKE_PROPERTY2(filename, has_filename, get_filename, set_filename, clear_filename);
322 INLINE
bool has_alpha_filename()
const;
323 INLINE
const Filename &get_alpha_filename()
const;
324 INLINE
void set_alpha_filename(
const Filename &alpha_filename);
325 INLINE
void clear_alpha_filename();
326 MAKE_PROPERTY2(alpha_filename, has_alpha_filename, get_alpha_filename, set_alpha_filename, clear_alpha_filename);
328 INLINE
bool has_fullpath()
const;
329 INLINE
const Filename &get_fullpath()
const;
330 INLINE
void set_fullpath(
const Filename &fullpath);
331 INLINE
void clear_fullpath();
332 MAKE_PROPERTY2(fullpath, has_fullpath, get_fullpath, set_fullpath, clear_fullpath);
334 INLINE
bool has_alpha_fullpath()
const;
335 INLINE
const Filename &get_alpha_fullpath()
const;
336 INLINE
void set_alpha_fullpath(
const Filename &alpha_fullpath);
337 INLINE
void clear_alpha_fullpath();
338 MAKE_PROPERTY2(alpha_fullpath, has_alpha_fullpath, get_alpha_fullpath, set_alpha_fullpath, clear_alpha_fullpath);
340 INLINE
int get_x_size()
const;
341 INLINE
void set_x_size(
int x_size);
342 MAKE_PROPERTY(x_size, get_x_size, set_x_size);
344 INLINE
int get_y_size()
const;
345 INLINE
void set_y_size(
int y_size);
346 MAKE_PROPERTY(y_size, get_y_size, set_y_size);
348 INLINE
int get_z_size()
const;
349 INLINE
void set_z_size(
int z_size);
350 MAKE_PROPERTY(z_size, get_z_size, set_z_size);
352 INLINE
int get_num_views()
const;
353 INLINE
void set_num_views(
int num_views);
354 MAKE_PROPERTY(num_views, get_num_views, set_num_views);
356 INLINE
int get_num_pages()
const;
357 INLINE
int get_num_components()
const;
358 INLINE
int get_component_width()
const;
359 INLINE TextureType get_texture_type()
const;
360 INLINE GeomEnums::UsageHint get_usage_hint()
const;
362 MAKE_PROPERTY(num_pages, get_num_pages);
363 MAKE_PROPERTY(num_components, get_num_components);
364 MAKE_PROPERTY(component_width, get_component_width);
365 MAKE_PROPERTY(texture_type, get_texture_type);
366 MAKE_PROPERTY(usage_hint, get_usage_hint);
368 INLINE Format get_format()
const;
369 INLINE
void set_format(Format format);
370 MAKE_PROPERTY(format, get_format, set_format);
372 INLINE ComponentType get_component_type()
const;
373 INLINE
void set_component_type(ComponentType component_type);
374 MAKE_PROPERTY(component_type, get_component_type, set_component_type);
376 INLINE SamplerState::WrapMode get_wrap_u()
const;
377 INLINE
void set_wrap_u(WrapMode wrap);
378 MAKE_PROPERTY(wrap_u, get_wrap_u, set_wrap_u);
380 INLINE SamplerState::WrapMode get_wrap_v()
const;
381 INLINE
void set_wrap_v(WrapMode wrap);
382 MAKE_PROPERTY(wrap_v, get_wrap_v, set_wrap_v);
384 INLINE SamplerState::WrapMode get_wrap_w()
const;
385 INLINE
void set_wrap_w(WrapMode wrap);
386 MAKE_PROPERTY(wrap_w, get_wrap_w, set_wrap_w);
388 INLINE SamplerState::FilterType get_minfilter()
const;
389 INLINE SamplerState::FilterType get_effective_minfilter()
const;
390 INLINE
void set_minfilter(FilterType filter);
391 MAKE_PROPERTY(minfilter, get_minfilter, set_minfilter);
392 MAKE_PROPERTY(effective_minfilter, get_effective_minfilter);
394 INLINE SamplerState::FilterType get_magfilter()
const;
395 INLINE SamplerState::FilterType get_effective_magfilter()
const;
396 INLINE
void set_magfilter(FilterType filter);
397 MAKE_PROPERTY(magfilter, get_magfilter, set_magfilter);
398 MAKE_PROPERTY(effective_magfilter, get_effective_magfilter);
400 INLINE
int get_anisotropic_degree()
const;
401 INLINE
int get_effective_anisotropic_degree()
const;
402 INLINE
void set_anisotropic_degree(
int anisotropic_degree);
403 MAKE_PROPERTY(anisotropic_degree, get_anisotropic_degree, set_anisotropic_degree);
404 MAKE_PROPERTY(effective_anisotropic_degree, get_effective_anisotropic_degree);
406 INLINE LColor get_border_color()
const;
407 INLINE
void set_border_color(
const LColor &color);
408 MAKE_PROPERTY(border_color, get_border_color, set_border_color);
410 INLINE
bool has_compression()
const;
411 INLINE CompressionMode get_compression()
const;
412 INLINE
void set_compression(CompressionMode compression);
413 MAKE_PROPERTY(compression, get_compression, set_compression);
415 INLINE
bool get_render_to_texture()
const;
416 INLINE
void set_render_to_texture(
bool render_to_texture);
417 MAKE_PROPERTY(render_to_texture, get_render_to_texture, set_render_to_texture);
420 INLINE
void set_default_sampler(
const SamplerState &sampler);
421 MAKE_PROPERTY(default_sampler, get_default_sampler, set_default_sampler);
422 INLINE
bool uses_mipmaps()
const;
424 INLINE QualityLevel get_quality_level()
const;
425 INLINE QualityLevel get_effective_quality_level()
const;
426 INLINE
void set_quality_level(QualityLevel quality_level);
427 MAKE_PROPERTY(quality_level, get_quality_level, set_quality_level);
428 MAKE_PROPERTY(effective_quality_level, get_effective_quality_level);
430 INLINE
int get_expected_num_mipmap_levels()
const;
431 INLINE
int get_expected_mipmap_x_size(
int n)
const;
432 INLINE
int get_expected_mipmap_y_size(
int n)
const;
433 INLINE
int get_expected_mipmap_z_size(
int n)
const;
434 INLINE
int get_expected_mipmap_num_pages(
int n)
const;
435 MAKE_PROPERTY(expected_num_mipmap_levels, get_expected_num_mipmap_levels);
437 INLINE
bool has_ram_image()
const;
438 INLINE
bool has_uncompressed_ram_image()
const;
439 INLINE
bool might_have_ram_image()
const;
440 INLINE
size_t get_ram_image_size()
const;
441 INLINE
size_t get_ram_view_size()
const;
442 INLINE
size_t get_ram_page_size()
const;
443 INLINE
size_t get_expected_ram_image_size()
const;
444 INLINE
size_t get_expected_ram_page_size()
const;
445 MAKE_PROPERTY(ram_image_size, get_ram_image_size);
446 MAKE_PROPERTY(ram_view_size, get_ram_view_size);
447 MAKE_PROPERTY(ram_page_size, get_ram_page_size);
448 MAKE_PROPERTY(expected_ram_image_size, get_expected_ram_image_size);
449 MAKE_PROPERTY(expected_ram_page_size, get_expected_ram_page_size);
452 INLINE CompressionMode get_ram_image_compression()
const;
453 INLINE
CPTA_uchar get_uncompressed_ram_image();
454 CPTA_uchar get_ram_image_as(
const std::string &requested_format);
455 INLINE PTA_uchar modify_ram_image();
456 INLINE PTA_uchar make_ram_image();
458 INLINE
void set_ram_image(
CPTA_uchar image, CompressionMode compression = CM_off,
459 size_t page_size = 0);
460 void set_ram_image_as(
CPTA_uchar image,
const std::string &provided_format);
462 EXTEND
void set_ram_image(PyObject *image, CompressionMode compression = CM_off,
463 size_t page_size = 0);
464 EXTEND
void set_ram_image_as(PyObject *image,
const std::string &provided_format);
466 INLINE
void clear_ram_image();
467 INLINE
void set_keep_ram_image(
bool keep_ram_image);
468 virtual bool get_keep_ram_image()
const;
469 virtual bool is_cacheable()
const;
471 MAKE_PROPERTY(ram_image_compression, get_ram_image_compression);
472 MAKE_PROPERTY(keep_ram_image, get_keep_ram_image, set_keep_ram_image);
473 MAKE_PROPERTY(cacheable, is_cacheable);
475 BLOCKING INLINE
bool compress_ram_image(CompressionMode compression = CM_on,
476 QualityLevel quality_level = QL_default,
478 BLOCKING INLINE
bool uncompress_ram_image();
480 INLINE
int get_num_ram_mipmap_images()
const;
481 INLINE
bool has_ram_mipmap_image(
int n)
const;
482 int get_num_loadable_ram_mipmap_images()
const;
483 INLINE
bool has_all_ram_mipmap_images()
const;
484 INLINE
size_t get_ram_mipmap_image_size(
int n)
const;
485 INLINE
size_t get_ram_mipmap_view_size(
int n)
const;
486 INLINE
size_t get_ram_mipmap_page_size(
int n)
const;
487 INLINE
size_t get_expected_ram_mipmap_image_size(
int n)
const;
488 INLINE
size_t get_expected_ram_mipmap_view_size(
int n)
const;
489 INLINE
size_t get_expected_ram_mipmap_page_size(
int n)
const;
491 void *get_ram_mipmap_pointer(
int n)
const;
492 INLINE PTA_uchar modify_ram_mipmap_image(
int n);
493 INLINE PTA_uchar make_ram_mipmap_image(
int n);
494 void set_ram_mipmap_pointer(
int n,
void *image,
size_t page_size = 0);
495 void set_ram_mipmap_pointer_from_int(
long long pointer,
int n,
int page_size);
496 INLINE
void set_ram_mipmap_image(
int n,
CPTA_uchar image,
size_t page_size = 0);
497 void clear_ram_mipmap_image(
int n);
498 INLINE
void clear_ram_mipmap_images();
499 INLINE
void generate_ram_mipmap_images();
501 MAKE_PROPERTY(num_ram_mipmap_images, get_num_ram_mipmap_images);
502 MAKE_PROPERTY(num_loadable_ram_mipmap_images, get_num_loadable_ram_mipmap_images);
504 INLINE
int get_simple_x_size()
const;
505 INLINE
int get_simple_y_size()
const;
506 INLINE
bool has_simple_ram_image()
const;
507 INLINE
size_t get_simple_ram_image_size()
const;
508 INLINE
CPTA_uchar get_simple_ram_image()
const;
509 INLINE
void set_simple_ram_image(
CPTA_uchar image,
int x_size,
int y_size);
510 PTA_uchar modify_simple_ram_image();
511 PTA_uchar new_simple_ram_image(
int x_size,
int y_size);
512 void generate_simple_ram_image();
513 INLINE
void clear_simple_ram_image();
515 MAKE_PROPERTY(simple_x_size, get_simple_x_size);
516 MAKE_PROPERTY(simple_y_size, get_simple_y_size);
517 MAKE_PROPERTY2(simple_ram_image, has_simple_ram_image, get_simple_ram_image);
521 INLINE
UpdateSeq get_properties_modified()
const;
522 INLINE
UpdateSeq get_image_modified()
const;
523 INLINE
UpdateSeq get_simple_image_modified()
const;
524 MAKE_PROPERTY(properties_modified, get_properties_modified);
525 MAKE_PROPERTY(image_modified, get_image_modified);
526 MAKE_PROPERTY(simple_image_modified, get_simple_image_modified);
528 INLINE
bool has_auto_texture_scale()
const;
529 INLINE AutoTextureScale get_auto_texture_scale()
const;
530 INLINE
void set_auto_texture_scale(AutoTextureScale scale);
531 MAKE_PROPERTY(auto_texture_scale, get_auto_texture_scale,
532 set_auto_texture_scale);
544 void write(std::ostream &out,
int indent_level)
const;
546 size_t estimate_texture_memory()
const;
549 void clear_aux_data(
const std::string &key);
551 MAKE_MAP_PROPERTY(aux_data, get_aux_data, get_aux_data,
552 set_aux_data, clear_aux_data);
554 INLINE
static void set_textures_power_2(AutoTextureScale scale);
555 INLINE
static AutoTextureScale get_textures_power_2();
556 INLINE
static bool has_textures_power_2();
560 INLINE
int get_pad_x_size()
const;
561 INLINE
int get_pad_y_size()
const;
562 INLINE
int get_pad_z_size()
const;
563 INLINE LVecBase2 get_tex_scale()
const;
565 INLINE
void set_pad_size(
int x=0,
int y=0,
int z=0);
566 void set_size_padded(
int x=1,
int y=1,
int z=1);
568 INLINE
int get_orig_file_x_size()
const;
569 INLINE
int get_orig_file_y_size()
const;
570 INLINE
int get_orig_file_z_size()
const;
572 MAKE_PROPERTY(orig_file_x_size, get_orig_file_x_size);
573 MAKE_PROPERTY(orig_file_y_size, get_orig_file_y_size);
574 MAKE_PROPERTY(orig_file_z_size, get_orig_file_z_size);
576 void set_orig_file_size(
int x,
int y,
int z = 1);
578 INLINE
void set_loaded_from_image(
bool flag =
true);
579 INLINE
bool get_loaded_from_image()
const;
580 MAKE_PROPERTY(loaded_from_image, get_loaded_from_image, set_loaded_from_image);
582 INLINE
void set_loaded_from_txo(
bool flag =
true);
583 INLINE
bool get_loaded_from_txo()
const;
584 MAKE_PROPERTY(loaded_from_txo, get_loaded_from_txo, set_loaded_from_txo);
586 INLINE
bool get_match_framebuffer_format()
const;
587 INLINE
void set_match_framebuffer_format(
bool flag);
588 MAKE_PROPERTY(match_framebuffer_format, get_match_framebuffer_format,
589 set_match_framebuffer_format);
591 INLINE
bool get_post_load_store_cache()
const;
592 INLINE
void set_post_load_store_cache(
bool flag);
593 MAKE_PROPERTY(post_load_store_cache, get_post_load_store_cache,
594 set_post_load_store_cache);
600 static int up_to_power_2(
int value);
601 static int down_to_power_2(
int value);
603 void consider_rescale(
PNMImage &pnmimage);
604 static void consider_rescale(
PNMImage &pnmimage,
const std::string &name, AutoTextureScale auto_texture_scale = ATS_unspecified);
605 INLINE
bool rescale_texture();
607 static std::string format_texture_type(TextureType tt);
608 static TextureType string_texture_type(
const std::string &str);
610 static std::string format_component_type(ComponentType ct);
611 static ComponentType string_component_type(
const std::string &str);
613 static std::string format_format(Format f);
614 static Format string_format(
const std::string &str);
616 static std::string format_compression_mode(CompressionMode cm);
617 static CompressionMode string_compression_mode(
const std::string &str);
619 static std::string format_quality_level(QualityLevel tql);
620 static QualityLevel string_quality_level(
const std::string &str);
623 void texture_uploaded();
625 virtual bool has_cull_callback()
const;
628 static PT(
Texture) make_texture();
631 static bool is_unsigned(ComponentType ctype);
632 static bool is_specific(CompressionMode compression);
633 static bool has_alpha(Format format);
634 static bool has_binary_alpha(Format format);
635 static bool is_srgb(Format format);
636 static bool is_integer(Format format);
638 static bool adjust_size(
int &x_size,
int &y_size,
const std::string &name,
639 bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified);
640 INLINE
bool adjust_this_size(
int &x_size,
int &y_size,
const std::string &name,
641 bool for_padding)
const;
643 virtual void ensure_loader_type(
const Filename &filename);
649 virtual void reconsider_dirty();
658 virtual bool do_adjust_this_size(
const CData *cdata,
659 int &x_size,
int &y_size,
const std::string &name,
660 bool for_padding)
const;
662 virtual bool do_read(CData *cdata,
664 int primary_file_num_channels,
int alpha_file_channel,
665 int z,
int n,
bool read_pages,
bool read_mipmaps,
667 virtual bool do_read_one(CData *cdata,
669 int z,
int n,
int primary_file_num_channels,
int alpha_file_channel,
672 virtual bool do_load_one(CData *cdata,
673 const PNMImage &pnmimage,
const std::string &name,
675 virtual bool do_load_one(CData *cdata,
676 const PfmFile &pfm,
const std::string &name,
678 virtual bool do_load_sub_image(CData *cdata,
const PNMImage &image,
679 int x,
int y,
int z,
int n);
680 bool do_read_txo_file(CData *cdata,
const Filename &fullpath);
681 bool do_read_txo(CData *cdata, std::istream &in,
const std::string &filename);
682 bool do_read_dds_file(CData *cdata,
const Filename &fullpath,
bool header_only);
683 bool do_read_dds(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
684 bool do_read_ktx_file(CData *cdata,
const Filename &fullpath,
bool header_only);
685 bool do_read_ktx(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
687 bool do_write(CData *cdata,
const Filename &fullpath,
int z,
int n,
688 bool write_pages,
bool write_mipmaps);
689 bool do_write_one(CData *cdata,
const Filename &fullpath,
int z,
int n);
690 bool do_store_one(CData *cdata,
PNMImage &pnmimage,
int z,
int n);
691 bool do_store_one(CData *cdata,
PfmFile &pfm,
int z,
int n);
692 bool do_write_txo_file(
const CData *cdata,
const Filename &fullpath)
const;
693 bool do_write_txo(
const CData *cdata, std::ostream &out,
const std::string &filename)
const;
695 virtual CData *unlocked_ensure_ram_image(
bool allow_compression);
696 virtual void do_reload_ram_image(CData *cdata,
bool allow_compression);
698 PTA_uchar do_modify_ram_image(CData *cdata);
699 PTA_uchar do_make_ram_image(CData *cdata);
700 void do_set_ram_image(CData *cdata,
CPTA_uchar image,
701 CompressionMode compression = CM_off,
size_t page_size = 0);
702 PTA_uchar do_modify_ram_mipmap_image(CData *cdata,
int n);
703 PTA_uchar do_make_ram_mipmap_image(CData *cdata,
int n);
704 void do_set_ram_mipmap_image(CData *cdata,
int n,
CPTA_uchar image,
size_t page_size);
705 size_t do_get_clear_data(
const CData *cdata,
unsigned char *into)
const;
707 bool consider_auto_process_ram_image(
bool generate_mipmaps,
bool allow_compression);
708 bool do_consider_auto_process_ram_image(CData *cdata,
bool generate_mipmaps,
709 bool allow_compression);
710 bool do_compress_ram_image(CData *cdata, CompressionMode compression,
711 QualityLevel quality_level,
713 bool do_uncompress_ram_image(CData *cdata);
715 static void do_compress_ram_image_bc4(
const RamImage &src, RamImage &dest,
716 int x_size,
int y_size,
int z_size);
717 static void do_compress_ram_image_bc5(
const RamImage &src, RamImage &dest,
718 int x_size,
int y_size,
int z_size);
719 static void do_uncompress_ram_image_bc4(
const RamImage &src, RamImage &dest,
720 int x_size,
int y_size,
int z_size);
721 static void do_uncompress_ram_image_bc5(
const RamImage &src, RamImage &dest,
722 int x_size,
int y_size,
int z_size);
723 bool do_has_all_ram_mipmap_images(
const CData *cdata)
const;
725 bool do_reconsider_z_size(CData *cdata,
int z,
const LoaderOptions &options);
726 virtual void do_allocate_pages(CData *cdata);
727 bool do_reconsider_image_properties(CData *cdata,
728 int x_size,
int y_size,
int num_components,
729 ComponentType component_type,
int z,
731 bool do_rescale_texture(CData *cdata);
733 virtual PT(
Texture) make_copy_impl()
const;
734 PT(
Texture) do_make_copy(
const CData *cdata)
const;
735 void do_assign(CData *cdata,
const Texture *copy,
const CData *cdata_copy);
736 virtual void do_clear(CData *cdata);
737 void do_setup_texture(CData *cdata,
738 TextureType texture_type,
int x_size,
int y_size,
739 int z_size, ComponentType component_type,
741 void do_set_num_views(CData *cdata,
int num_views);
742 void do_set_format(CData *cdata, Format format);
743 void do_set_component_type(CData *cdata, ComponentType component_type);
744 void do_set_x_size(CData *cdata,
int x_size);
745 void do_set_y_size(CData *cdata,
int y_size);
746 void do_set_z_size(CData *cdata,
int z_size);
748 void do_set_wrap_u(CData *cdata, WrapMode wrap);
749 void do_set_wrap_v(CData *cdata, WrapMode wrap);
750 void do_set_wrap_w(CData *cdata, WrapMode wrap);
751 void do_set_minfilter(CData *cdata, FilterType filter);
752 void do_set_magfilter(CData *cdata, FilterType filter);
753 void do_set_anisotropic_degree(CData *cdata,
int anisotropic_degree);
754 void do_set_border_color(CData *cdata,
const LColor &color);
755 void do_set_compression(CData *cdata, CompressionMode compression);
756 void do_set_quality_level(CData *cdata, QualityLevel quality_level);
758 bool do_has_compression(
const CData *cdata)
const;
759 virtual bool do_has_ram_image(
const CData *cdata)
const;
760 virtual bool do_has_uncompressed_ram_image(
const CData *cdata)
const;
762 CPTA_uchar do_get_uncompressed_ram_image(CData *cdata);
763 void do_set_simple_ram_image(CData *cdata,
CPTA_uchar image,
int x_size,
int y_size);
764 INLINE
size_t do_get_ram_image_size(
const CData *cdata)
const;
765 INLINE
bool do_has_ram_mipmap_image(
const CData *cdata,
int n)
const;
766 int do_get_expected_num_mipmap_levels(
const CData *cdata)
const;
767 INLINE
size_t do_get_expected_ram_image_size(
const CData *cdata)
const;
768 INLINE
size_t do_get_expected_ram_view_size(
const CData *cdata)
const;
769 INLINE
size_t do_get_expected_ram_page_size(
const CData *cdata)
const;
770 size_t do_get_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
771 INLINE
size_t do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const;
772 INLINE
size_t do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const;
773 INLINE
size_t do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
774 int do_get_expected_mipmap_x_size(
const CData *cdata,
int n)
const;
775 int do_get_expected_mipmap_y_size(
const CData *cdata,
int n)
const;
776 int do_get_expected_mipmap_z_size(
const CData *cdata,
int n)
const;
777 INLINE
int do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const;
778 INLINE
void do_clear_ram_image(CData *cdata);
779 void do_clear_simple_ram_image(CData *cdata);
780 void do_clear_ram_mipmap_images(CData *cdata);
781 void do_generate_ram_mipmap_images(CData *cdata,
bool allow_recompress);
782 void do_set_pad_size(CData *cdata,
int x,
int y,
int z);
783 virtual bool do_can_reload(
const CData *cdata)
const;
784 bool do_reload(CData *cdata);
786 INLINE AutoTextureScale do_get_auto_texture_scale(
const CData *cdata)
const;
788 virtual bool do_has_bam_rawdata(
const CData *cdata)
const;
789 virtual void do_get_bam_rawdata(CData *cdata);
801 void *_pointer_image;
805 static void convert_from_pnmimage(PTA_uchar &image,
size_t page_size,
806 int row_stride,
int x,
int y,
int z,
808 int num_components,
int component_width);
809 static void convert_from_pfm(PTA_uchar &image,
size_t page_size,
811 int num_components,
int component_width);
812 static bool convert_to_pnmimage(
PNMImage &pnmimage,
int x_size,
int y_size,
814 ComponentType component_type,
bool is_srgb,
817 static bool convert_to_pfm(
PfmFile &pfm,
int x_size,
int y_size,
818 int num_components,
int component_width,
821 static PTA_uchar read_dds_level_bgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
822 int n, std::istream &in);
823 static PTA_uchar read_dds_level_rgb8(
Texture *tex, CData *cdata,
const DDSHeader &header,
824 int n, std::istream &in);
825 static PTA_uchar read_dds_level_abgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
826 int n, std::istream &in);
827 static PTA_uchar read_dds_level_rgba8(
Texture *tex, CData *cdata,
const DDSHeader &header,
828 int n, std::istream &in);
829 static PTA_uchar read_dds_level_abgr16(
Texture *tex, CData *cdata,
const DDSHeader &header,
830 int n, std::istream &in);
831 static PTA_uchar read_dds_level_abgr32(
Texture *tex, CData *cdata,
const DDSHeader &header,
832 int n, std::istream &in);
833 static PTA_uchar read_dds_level_raw(
Texture *tex, CData *cdata,
const DDSHeader &header,
834 int n, std::istream &in);
835 static PTA_uchar read_dds_level_generic_uncompressed(
Texture *tex, CData *cdata,
836 const DDSHeader &header,
837 int n, std::istream &in);
838 static PTA_uchar read_dds_level_luminance_uncompressed(
Texture *tex, CData *cdata,
839 const DDSHeader &header,
840 int n, std::istream &in);
841 static PTA_uchar read_dds_level_bc1(
Texture *tex, CData *cdata,
842 const DDSHeader &header,
843 int n, std::istream &in);
844 static PTA_uchar read_dds_level_bc2(
Texture *tex, CData *cdata,
845 const DDSHeader &header,
846 int n, std::istream &in);
847 static PTA_uchar read_dds_level_bc3(
Texture *tex, CData *cdata,
848 const DDSHeader &header,
849 int n, std::istream &in);
850 static PTA_uchar read_dds_level_bc4(
Texture *tex, CData *cdata,
851 const DDSHeader &header,
852 int n, std::istream &in);
853 static PTA_uchar read_dds_level_bc5(
Texture *tex, CData *cdata,
854 const DDSHeader &header,
855 int n, std::istream &in);
859 static void consider_downgrade(
PNMImage &pnmimage,
int num_channels,
const std::string &name);
863 INLINE
static void store_unscaled_byte(
unsigned char *&p,
int value);
864 INLINE
static void store_unscaled_short(
unsigned char *&p,
int value);
865 INLINE
static void store_scaled_byte(
unsigned char *&p,
int value,
double scale);
866 INLINE
static void store_scaled_short(
unsigned char *&p,
int value,
double scale);
867 INLINE
static double get_unsigned_byte(
const unsigned char *&p);
868 INLINE
static double get_unsigned_short(
const unsigned char *&p);
869 INLINE
static double get_unsigned_int(
const unsigned char *&p);
870 INLINE
static double get_unsigned_int_24(
const unsigned char *&p);
871 INLINE
static double get_float(
const unsigned char *&p);
872 INLINE
static double get_half_float(
const unsigned char *&p);
874 INLINE
static bool is_txo_filename(
const Filename &fullpath);
875 INLINE
static bool is_dds_filename(
const Filename &fullpath);
876 INLINE
static bool is_ktx_filename(
const Filename &fullpath);
878 void do_filter_2d_mipmap_pages(
const CData *cdata,
879 RamImage &to,
const RamImage &from,
880 int x_size,
int y_size)
const;
882 void do_filter_3d_mipmap_level(
const CData *cdata,
883 RamImage &to,
const RamImage &from,
884 int x_size,
int y_size,
int z_size)
const;
886 typedef void Filter2DComponent(
unsigned char *&p,
887 const unsigned char *&q,
888 size_t pixel_size,
size_t row_size);
890 typedef void Filter3DComponent(
unsigned char *&p,
891 const unsigned char *&q,
892 size_t pixel_size,
size_t row_size,
895 static void filter_2d_unsigned_byte(
unsigned char *&p,
896 const unsigned char *&q,
897 size_t pixel_size,
size_t row_size);
898 static void filter_2d_unsigned_byte_srgb(
unsigned char *&p,
899 const unsigned char *&q,
900 size_t pixel_size,
size_t row_size);
901 static void filter_2d_unsigned_byte_srgb_sse2(
unsigned char *&p,
902 const unsigned char *&q,
903 size_t pixel_size,
size_t row_size);
904 static void filter_2d_unsigned_short(
unsigned char *&p,
905 const unsigned char *&q,
906 size_t pixel_size,
size_t row_size);
907 static void filter_2d_float(
unsigned char *&p,
const unsigned char *&q,
908 size_t pixel_size,
size_t row_size);
910 static void filter_3d_unsigned_byte(
unsigned char *&p,
911 const unsigned char *&q,
912 size_t pixel_size,
size_t row_size,
914 static void filter_3d_unsigned_byte_srgb(
unsigned char *&p,
915 const unsigned char *&q,
916 size_t pixel_size,
size_t row_size,
918 static void filter_3d_unsigned_byte_srgb_sse2(
unsigned char *&p,
919 const unsigned char *&q,
920 size_t pixel_size,
size_t row_size,
922 static void filter_3d_unsigned_short(
unsigned char *&p,
923 const unsigned char *&q,
924 size_t pixel_size,
size_t row_size,
926 static void filter_3d_float(
unsigned char *&p,
const unsigned char *&q,
927 size_t pixel_size,
size_t row_size,
size_t page_size);
929 bool do_squish(CData *cdata, CompressionMode compression,
int squish_flags);
930 bool do_unsquish(CData *cdata,
int squish_flags);
936 class EXPCL_PANDA_GOBJ CData :
public CycleData {
939 CData(
const CData ©);
940 ALLOC_DELETED_CHAIN(CData);
946 return Texture::get_class_type();
949 void do_assign(
const CData *copy);
950 INLINE
void inc_properties_modified();
951 INLINE
void inc_image_modified();
952 INLINE
void inc_simple_image_modified();
960 int _primary_file_num_channels;
965 int _alpha_file_channel;
972 int _component_width;
973 TextureType _texture_type;
975 ComponentType _component_type;
976 GeomEnums::UsageHint _usage_hint;
978 bool _loaded_from_image;
979 bool _loaded_from_txo;
980 bool _has_read_pages;
981 bool _has_read_mipmaps;
982 int _num_mipmap_levels_read;
985 bool _keep_ram_image;
986 LColor _border_color;
987 CompressionMode _compression;
988 bool _render_to_texture;
989 bool _match_framebuffer_format;
990 bool _post_load_store_cache;
991 QualityLevel _quality_level;
997 int _orig_file_x_size;
998 int _orig_file_y_size;
1000 AutoTextureScale _auto_texture_scale;
1001 CompressionMode _ram_image_compression;
1006 RamImages _ram_images;
1010 RamImage _simple_ram_image;
1013 int32_t _simple_image_date_generated;
1016 bool _has_clear_color;
1017 LColor _clear_color;
1025 return _type_handle;
1027 static void init_type() {
1056 PreparedViews _prepared_views;
1064 RelatedTextures _related_textures;
1074 static AutoTextureScale _textures_power_2;
1079 static void register_with_read_factory();
1085 void do_write_datagram_header(CData *cdata,
BamWriter *manager,
Datagram &me,
bool &has_rawdata);
1086 virtual void do_write_datagram_body(CData *cdata,
BamWriter *manager,
Datagram &me);
1087 virtual void do_write_datagram_rawdata(CData *cdata,
BamWriter *manager,
Datagram &me);
1092 virtual void do_fillin_from(CData *cdata,
const Texture *dummy);
1096 return _type_handle;
1098 static void init_type() {
1099 TypedWritableReferenceCount::init_type();
1101 TypedWritableReferenceCount::get_class_type());
1105 return get_class_type();
1107 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
1121 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::TextureType tt);
1122 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::ComponentType ct);
1123 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::Format f);
1125 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::CompressionMode cm);
1126 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::QualityLevel tql);
1127 EXPCL_PANDA_GOBJ std::istream &operator >> (std::istream &in, Texture::QualityLevel &tql);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This class implements a condition variable; see ConditionVar for a brief introduction to this class.
This class specializes ConfigVariable as an enumerated type.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A single page of data maintained by a PipelineCycler.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
The name of a file, such as a texture file or an Egg file.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Encodes a string name in a hash table, mapping it to a pointer.
Specifies parameters that may be passed to the loader.
A standard mutex, or mutual exclusion lock.
A base class for all things which can have a name.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
A lightweight class that represents a single element that may be timed and/or counted via stats.
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
A table of objects that are saved within the graphics context for reference by handle later.
Represents a set of settings that indicate how a texture is sampled.
This is a special class object that holds all the information returned by a particular GSG to indicat...
An instance of this object is returned by Texture::peek().
This is the preferred interface for loading textures from image files.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
TypeHandle is the identifier used to differentiate C++ class types.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Base class for objects that can be written to and read from Bam files.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is a sequence number that increments monotonically.
This is our own Panda specialization on the default STL list.
This is our own Panda specialization on the default STL map.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.