73 typedef PT(
Texture) MakeTextureFunc();
128 F_luminance_alphamask,
168 enum DeprecatedFilterType {
169 FT_nearest = SamplerState::FT_nearest,
170 FT_linear = SamplerState::FT_linear,
171 FT_nearest_mipmap_nearest = SamplerState::FT_nearest_mipmap_nearest,
172 FT_linear_mipmap_nearest = SamplerState::FT_linear_mipmap_nearest,
173 FT_nearest_mipmap_linear = SamplerState::FT_nearest_mipmap_linear,
174 FT_linear_mipmap_linear = SamplerState::FT_linear_mipmap_linear,
175 FT_shadow = SamplerState::FT_shadow,
176 FT_default = SamplerState::FT_default,
177 FT_invalid = SamplerState::FT_invalid
179 typedef SamplerState::FilterType FilterType;
182 enum DeprecatedWrapMode {
183 WM_clamp = SamplerState::WM_clamp,
184 WM_repeat = SamplerState::WM_repeat,
185 WM_mirror = SamplerState::WM_mirror,
186 WM_mirror_once = SamplerState::WM_mirror_once,
187 WM_border_color = SamplerState::WM_border_color,
188 WM_invalid = SamplerState::WM_invalid
190 typedef SamplerState::WrapMode WrapMode;
192 enum CompressionMode {
225 explicit Texture(
const std::string &name = std::string());
229 void operator = (
const Texture ©);
234 INLINE PT(
Texture) make_copy()
const;
237 INLINE
void setup_texture(TextureType texture_type,
238 int x_size,
int y_size,
int z_size,
239 ComponentType component_type, Format format);
240 INLINE
void setup_1d_texture();
241 INLINE
void setup_1d_texture(
int x_size,
242 ComponentType component_type, Format format);
243 INLINE
void setup_2d_texture();
244 INLINE
void setup_2d_texture(
int x_size,
int y_size,
245 ComponentType component_type, Format format);
246 INLINE
void setup_3d_texture(
int z_size = 1);
247 INLINE
void setup_3d_texture(
int x_size,
int y_size,
int z_size,
248 ComponentType component_type, Format format);
249 INLINE
void setup_cube_map();
250 INLINE
void setup_cube_map(
int size,
251 ComponentType component_type, Format format);
252 INLINE
void setup_2d_texture_array(
int z_size = 1);
253 INLINE
void setup_2d_texture_array(
int x_size,
int y_size,
int z_size,
254 ComponentType component_type, Format format);
255 INLINE
void setup_cube_map_array(
int num_cube_maps);
256 INLINE
void setup_cube_map_array(
int size,
int num_cube_maps,
257 ComponentType component_type, Format format);
258 INLINE
void setup_buffer_texture(
int size, ComponentType component_type,
259 Format format, GeomEnums::UsageHint usage);
260 void generate_normalization_cube_map(
int size);
261 void generate_alpha_scale_map();
263 INLINE
void clear_image();
264 INLINE
bool has_clear_color()
const;
265 INLINE LColor get_clear_color()
const;
266 INLINE
void set_clear_color(
const LColor &color);
267 INLINE
void clear_clear_color();
268 INLINE vector_uchar get_clear_data()
const;
269 MAKE_PROPERTY2(clear_color, has_clear_color, get_clear_color,
270 set_clear_color, clear_clear_color);
273 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
274 int primary_file_num_channels,
int alpha_file_channel,
276 BLOCKING
bool read(
const Filename &fullpath,
int z,
int n,
277 bool read_pages,
bool read_mipmaps,
279 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
280 int primary_file_num_channels,
int alpha_file_channel,
281 int z,
int n,
bool read_pages,
bool read_mipmaps,
285 BLOCKING INLINE
bool write(
const Filename &fullpath);
286 BLOCKING INLINE
bool write(
const Filename &fullpath,
int z,
int n,
287 bool write_pages,
bool write_mipmaps);
289 BLOCKING
bool read_txo(std::istream &in,
const std::string &filename =
"");
290 BLOCKING
static PT(
Texture) make_from_txo(std::istream &in,
const std::string &filename =
"");
291 BLOCKING
bool write_txo(std::ostream &out,
const std::string &filename =
"")
const;
292 BLOCKING
bool read_dds(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
293 BLOCKING
bool read_ktx(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
299 BLOCKING INLINE
bool load_sub_image(
const PNMImage &pnmimage,
int x,
int y,
int z=0,
int n=0);
300 BLOCKING INLINE
bool store(
PNMImage &pnmimage)
const;
301 BLOCKING INLINE
bool store(
PNMImage &pnmimage,
int z,
int n)
const;
302 BLOCKING INLINE
bool store(
PfmFile &pfm)
const;
303 BLOCKING INLINE
bool store(
PfmFile &pfm,
int z,
int n)
const;
305 BLOCKING INLINE
bool reload();
308 INLINE
bool has_filename()
const;
309 INLINE
const Filename &get_filename()
const;
310 INLINE
void set_filename(
const Filename &filename);
311 INLINE
void clear_filename();
312 MAKE_PROPERTY2(filename, has_filename, get_filename, set_filename, clear_filename);
314 INLINE
bool has_alpha_filename()
const;
315 INLINE
const Filename &get_alpha_filename()
const;
316 INLINE
void set_alpha_filename(
const Filename &alpha_filename);
317 INLINE
void clear_alpha_filename();
318 MAKE_PROPERTY2(alpha_filename, has_alpha_filename, get_alpha_filename, set_alpha_filename, clear_alpha_filename);
320 INLINE
bool has_fullpath()
const;
321 INLINE
const Filename &get_fullpath()
const;
322 INLINE
void set_fullpath(
const Filename &fullpath);
323 INLINE
void clear_fullpath();
324 MAKE_PROPERTY2(fullpath, has_fullpath, get_fullpath, set_fullpath, clear_fullpath);
326 INLINE
bool has_alpha_fullpath()
const;
327 INLINE
const Filename &get_alpha_fullpath()
const;
328 INLINE
void set_alpha_fullpath(
const Filename &alpha_fullpath);
329 INLINE
void clear_alpha_fullpath();
330 MAKE_PROPERTY2(alpha_fullpath, has_alpha_fullpath, get_alpha_fullpath, set_alpha_fullpath, clear_alpha_fullpath);
332 INLINE
int get_x_size()
const;
333 INLINE
void set_x_size(
int x_size);
334 MAKE_PROPERTY(x_size, get_x_size, set_x_size);
336 INLINE
int get_y_size()
const;
337 INLINE
void set_y_size(
int y_size);
338 MAKE_PROPERTY(y_size, get_y_size, set_y_size);
340 INLINE
int get_z_size()
const;
341 INLINE
void set_z_size(
int z_size);
342 MAKE_PROPERTY(z_size, get_z_size, set_z_size);
344 INLINE
int get_num_views()
const;
345 INLINE
void set_num_views(
int num_views);
346 MAKE_PROPERTY(num_views, get_num_views, set_num_views);
348 INLINE
int get_num_pages()
const;
349 INLINE
int get_num_components()
const;
350 INLINE
int get_component_width()
const;
351 INLINE TextureType get_texture_type()
const;
352 INLINE GeomEnums::UsageHint get_usage_hint()
const;
354 MAKE_PROPERTY(num_pages, get_num_pages);
355 MAKE_PROPERTY(num_components, get_num_components);
356 MAKE_PROPERTY(component_width, get_component_width);
357 MAKE_PROPERTY(texture_type, get_texture_type);
358 MAKE_PROPERTY(usage_hint, get_usage_hint);
360 INLINE Format get_format()
const;
361 INLINE
void set_format(Format format);
362 MAKE_PROPERTY(format, get_format, set_format);
364 INLINE ComponentType get_component_type()
const;
365 INLINE
void set_component_type(ComponentType component_type);
366 MAKE_PROPERTY(component_type, get_component_type, set_component_type);
368 INLINE SamplerState::WrapMode get_wrap_u()
const;
369 INLINE
void set_wrap_u(WrapMode wrap);
370 MAKE_PROPERTY(wrap_u, get_wrap_u, set_wrap_u);
372 INLINE SamplerState::WrapMode get_wrap_v()
const;
373 INLINE
void set_wrap_v(WrapMode wrap);
374 MAKE_PROPERTY(wrap_v, get_wrap_v, set_wrap_v);
376 INLINE SamplerState::WrapMode get_wrap_w()
const;
377 INLINE
void set_wrap_w(WrapMode wrap);
378 MAKE_PROPERTY(wrap_w, get_wrap_w, set_wrap_w);
380 INLINE SamplerState::FilterType get_minfilter()
const;
381 INLINE SamplerState::FilterType get_effective_minfilter()
const;
382 INLINE
void set_minfilter(FilterType filter);
383 MAKE_PROPERTY(minfilter, get_minfilter, set_minfilter);
384 MAKE_PROPERTY(effective_minfilter, get_effective_minfilter);
386 INLINE SamplerState::FilterType get_magfilter()
const;
387 INLINE SamplerState::FilterType get_effective_magfilter()
const;
388 INLINE
void set_magfilter(FilterType filter);
389 MAKE_PROPERTY(magfilter, get_magfilter, set_magfilter);
390 MAKE_PROPERTY(effective_magfilter, get_effective_magfilter);
392 INLINE
int get_anisotropic_degree()
const;
393 INLINE
int get_effective_anisotropic_degree()
const;
394 INLINE
void set_anisotropic_degree(
int anisotropic_degree);
395 MAKE_PROPERTY(anisotropic_degree, get_anisotropic_degree, set_anisotropic_degree);
396 MAKE_PROPERTY(effective_anisotropic_degree, get_effective_anisotropic_degree);
398 INLINE LColor get_border_color()
const;
399 INLINE
void set_border_color(
const LColor &color);
400 MAKE_PROPERTY(border_color, get_border_color, set_border_color);
402 INLINE
bool has_compression()
const;
403 INLINE CompressionMode get_compression()
const;
404 INLINE
void set_compression(CompressionMode compression);
405 MAKE_PROPERTY(compression, get_compression, set_compression);
407 INLINE
bool get_render_to_texture()
const;
408 INLINE
void set_render_to_texture(
bool render_to_texture);
409 MAKE_PROPERTY(render_to_texture, get_render_to_texture, set_render_to_texture);
412 INLINE
void set_default_sampler(
const SamplerState &sampler);
413 MAKE_PROPERTY(default_sampler, get_default_sampler, set_default_sampler);
414 INLINE
bool uses_mipmaps()
const;
416 INLINE QualityLevel get_quality_level()
const;
417 INLINE QualityLevel get_effective_quality_level()
const;
418 INLINE
void set_quality_level(QualityLevel quality_level);
419 MAKE_PROPERTY(quality_level, get_quality_level, set_quality_level);
420 MAKE_PROPERTY(effective_quality_level, get_effective_quality_level);
422 INLINE
int get_expected_num_mipmap_levels()
const;
423 INLINE
int get_expected_mipmap_x_size(
int n)
const;
424 INLINE
int get_expected_mipmap_y_size(
int n)
const;
425 INLINE
int get_expected_mipmap_z_size(
int n)
const;
426 INLINE
int get_expected_mipmap_num_pages(
int n)
const;
427 MAKE_PROPERTY(expected_num_mipmap_levels, get_expected_num_mipmap_levels);
429 INLINE
bool has_ram_image()
const;
430 INLINE
bool has_uncompressed_ram_image()
const;
431 INLINE
bool might_have_ram_image()
const;
432 INLINE
size_t get_ram_image_size()
const;
433 INLINE
size_t get_ram_view_size()
const;
434 INLINE
size_t get_ram_page_size()
const;
435 INLINE
size_t get_expected_ram_image_size()
const;
436 INLINE
size_t get_expected_ram_page_size()
const;
437 MAKE_PROPERTY(ram_image_size, get_ram_image_size);
438 MAKE_PROPERTY(ram_view_size, get_ram_view_size);
439 MAKE_PROPERTY(ram_page_size, get_ram_page_size);
440 MAKE_PROPERTY(expected_ram_image_size, get_expected_ram_image_size);
441 MAKE_PROPERTY(expected_ram_page_size, get_expected_ram_page_size);
444 INLINE CompressionMode get_ram_image_compression()
const;
445 INLINE
CPTA_uchar get_uncompressed_ram_image();
446 CPTA_uchar get_ram_image_as(
const std::string &requested_format);
447 INLINE PTA_uchar modify_ram_image();
448 INLINE PTA_uchar make_ram_image();
450 INLINE
void set_ram_image(
CPTA_uchar image, CompressionMode compression = CM_off,
451 size_t page_size = 0);
452 void set_ram_image_as(
CPTA_uchar image,
const std::string &provided_format);
454 EXTEND
void set_ram_image(PyObject *image, CompressionMode compression = CM_off,
455 size_t page_size = 0);
456 EXTEND
void set_ram_image_as(PyObject *image,
const std::string &provided_format);
458 INLINE
void clear_ram_image();
459 INLINE
void set_keep_ram_image(
bool keep_ram_image);
460 virtual bool get_keep_ram_image()
const;
461 virtual bool is_cacheable()
const;
463 MAKE_PROPERTY(ram_image_compression, get_ram_image_compression);
464 MAKE_PROPERTY(keep_ram_image, get_keep_ram_image, set_keep_ram_image);
465 MAKE_PROPERTY(cacheable, is_cacheable);
467 BLOCKING INLINE
bool compress_ram_image(CompressionMode compression = CM_on,
468 QualityLevel quality_level = QL_default,
470 BLOCKING INLINE
bool uncompress_ram_image();
472 INLINE
int get_num_ram_mipmap_images()
const;
473 INLINE
bool has_ram_mipmap_image(
int n)
const;
474 int get_num_loadable_ram_mipmap_images()
const;
475 INLINE
bool has_all_ram_mipmap_images()
const;
476 INLINE
size_t get_ram_mipmap_image_size(
int n)
const;
477 INLINE
size_t get_ram_mipmap_view_size(
int n)
const;
478 INLINE
size_t get_ram_mipmap_page_size(
int n)
const;
479 INLINE
size_t get_expected_ram_mipmap_image_size(
int n)
const;
480 INLINE
size_t get_expected_ram_mipmap_view_size(
int n)
const;
481 INLINE
size_t get_expected_ram_mipmap_page_size(
int n)
const;
483 void *get_ram_mipmap_pointer(
int n)
const;
484 INLINE PTA_uchar modify_ram_mipmap_image(
int n);
485 INLINE PTA_uchar make_ram_mipmap_image(
int n);
486 void set_ram_mipmap_pointer(
int n,
void *image,
size_t page_size = 0);
487 void set_ram_mipmap_pointer_from_int(
long long pointer,
int n,
int page_size);
488 INLINE
void set_ram_mipmap_image(
int n,
CPTA_uchar image,
size_t page_size = 0);
489 void clear_ram_mipmap_image(
int n);
490 INLINE
void clear_ram_mipmap_images();
491 INLINE
void generate_ram_mipmap_images();
493 MAKE_PROPERTY(num_ram_mipmap_images, get_num_ram_mipmap_images);
494 MAKE_PROPERTY(num_loadable_ram_mipmap_images, get_num_loadable_ram_mipmap_images);
496 INLINE
int get_simple_x_size()
const;
497 INLINE
int get_simple_y_size()
const;
498 INLINE
bool has_simple_ram_image()
const;
499 INLINE
size_t get_simple_ram_image_size()
const;
500 INLINE
CPTA_uchar get_simple_ram_image()
const;
501 INLINE
void set_simple_ram_image(
CPTA_uchar image,
int x_size,
int y_size);
502 PTA_uchar modify_simple_ram_image();
503 PTA_uchar new_simple_ram_image(
int x_size,
int y_size);
504 void generate_simple_ram_image();
505 INLINE
void clear_simple_ram_image();
507 MAKE_PROPERTY(simple_x_size, get_simple_x_size);
508 MAKE_PROPERTY(simple_y_size, get_simple_y_size);
509 MAKE_PROPERTY2(simple_ram_image, has_simple_ram_image, get_simple_ram_image);
513 INLINE
UpdateSeq get_properties_modified()
const;
514 INLINE
UpdateSeq get_image_modified()
const;
515 INLINE
UpdateSeq get_simple_image_modified()
const;
516 MAKE_PROPERTY(properties_modified, get_properties_modified);
517 MAKE_PROPERTY(image_modified, get_image_modified);
518 MAKE_PROPERTY(simple_image_modified, get_simple_image_modified);
520 INLINE
bool has_auto_texture_scale()
const;
521 INLINE AutoTextureScale get_auto_texture_scale()
const;
522 INLINE
void set_auto_texture_scale(AutoTextureScale scale);
523 MAKE_PROPERTY(auto_texture_scale, get_auto_texture_scale,
524 set_auto_texture_scale);
536 void write(std::ostream &out,
int indent_level)
const;
538 size_t estimate_texture_memory()
const;
541 void clear_aux_data(
const std::string &key);
543 MAKE_MAP_PROPERTY(aux_data, get_aux_data, get_aux_data,
544 set_aux_data, clear_aux_data);
546 INLINE
static void set_textures_power_2(AutoTextureScale scale);
547 INLINE
static AutoTextureScale get_textures_power_2();
548 INLINE
static bool has_textures_power_2();
552 INLINE
int get_pad_x_size()
const;
553 INLINE
int get_pad_y_size()
const;
554 INLINE
int get_pad_z_size()
const;
555 INLINE LVecBase2 get_tex_scale()
const;
557 INLINE
void set_pad_size(
int x=0,
int y=0,
int z=0);
558 void set_size_padded(
int x=1,
int y=1,
int z=1);
560 INLINE
int get_orig_file_x_size()
const;
561 INLINE
int get_orig_file_y_size()
const;
562 INLINE
int get_orig_file_z_size()
const;
564 MAKE_PROPERTY(orig_file_x_size, get_orig_file_x_size);
565 MAKE_PROPERTY(orig_file_y_size, get_orig_file_y_size);
566 MAKE_PROPERTY(orig_file_z_size, get_orig_file_z_size);
568 void set_orig_file_size(
int x,
int y,
int z = 1);
570 INLINE
void set_loaded_from_image(
bool flag =
true);
571 INLINE
bool get_loaded_from_image()
const;
572 MAKE_PROPERTY(loaded_from_image, get_loaded_from_image, set_loaded_from_image);
574 INLINE
void set_loaded_from_txo(
bool flag =
true);
575 INLINE
bool get_loaded_from_txo()
const;
576 MAKE_PROPERTY(loaded_from_txo, get_loaded_from_txo, set_loaded_from_txo);
578 INLINE
bool get_match_framebuffer_format()
const;
579 INLINE
void set_match_framebuffer_format(
bool flag);
580 MAKE_PROPERTY(match_framebuffer_format, get_match_framebuffer_format,
581 set_match_framebuffer_format);
583 INLINE
bool get_post_load_store_cache()
const;
584 INLINE
void set_post_load_store_cache(
bool flag);
585 MAKE_PROPERTY(post_load_store_cache, get_post_load_store_cache,
586 set_post_load_store_cache);
592 static int up_to_power_2(
int value);
593 static int down_to_power_2(
int value);
595 void consider_rescale(
PNMImage &pnmimage);
596 static void consider_rescale(
PNMImage &pnmimage,
const std::string &name, AutoTextureScale auto_texture_scale = ATS_unspecified);
597 INLINE
bool rescale_texture();
599 static std::string format_texture_type(TextureType tt);
600 static TextureType string_texture_type(
const std::string &str);
602 static std::string format_component_type(ComponentType ct);
603 static ComponentType string_component_type(
const std::string &str);
605 static std::string format_format(Format f);
606 static Format string_format(
const std::string &str);
608 static std::string format_compression_mode(CompressionMode cm);
609 static CompressionMode string_compression_mode(
const std::string &str);
611 static std::string format_quality_level(QualityLevel tql);
612 static QualityLevel string_quality_level(
const std::string &str);
615 void texture_uploaded();
617 virtual bool has_cull_callback()
const;
620 static PT(
Texture) make_texture();
623 static bool is_unsigned(ComponentType ctype);
624 static bool is_specific(CompressionMode compression);
625 static bool has_alpha(Format format);
626 static bool has_binary_alpha(Format format);
627 static bool is_srgb(Format format);
629 static bool adjust_size(
int &x_size,
int &y_size,
const std::string &name,
630 bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified);
631 INLINE
bool adjust_this_size(
int &x_size,
int &y_size,
const std::string &name,
632 bool for_padding)
const;
634 virtual void ensure_loader_type(
const Filename &filename);
640 virtual void reconsider_dirty();
649 virtual bool do_adjust_this_size(
const CData *cdata,
650 int &x_size,
int &y_size,
const std::string &name,
651 bool for_padding)
const;
653 virtual bool do_read(CData *cdata,
655 int primary_file_num_channels,
int alpha_file_channel,
656 int z,
int n,
bool read_pages,
bool read_mipmaps,
658 virtual bool do_read_one(CData *cdata,
660 int z,
int n,
int primary_file_num_channels,
int alpha_file_channel,
663 virtual bool do_load_one(CData *cdata,
664 const PNMImage &pnmimage,
const std::string &name,
666 virtual bool do_load_one(CData *cdata,
667 const PfmFile &pfm,
const std::string &name,
669 virtual bool do_load_sub_image(CData *cdata,
const PNMImage &image,
670 int x,
int y,
int z,
int n);
671 bool do_read_txo_file(CData *cdata,
const Filename &fullpath);
672 bool do_read_txo(CData *cdata, std::istream &in,
const std::string &filename);
673 bool do_read_dds_file(CData *cdata,
const Filename &fullpath,
bool header_only);
674 bool do_read_dds(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
675 bool do_read_ktx_file(CData *cdata,
const Filename &fullpath,
bool header_only);
676 bool do_read_ktx(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
678 bool do_write(CData *cdata,
const Filename &fullpath,
int z,
int n,
679 bool write_pages,
bool write_mipmaps);
680 bool do_write_one(CData *cdata,
const Filename &fullpath,
int z,
int n);
681 bool do_store_one(CData *cdata,
PNMImage &pnmimage,
int z,
int n);
682 bool do_store_one(CData *cdata,
PfmFile &pfm,
int z,
int n);
683 bool do_write_txo_file(
const CData *cdata,
const Filename &fullpath)
const;
684 bool do_write_txo(
const CData *cdata, std::ostream &out,
const std::string &filename)
const;
686 virtual CData *unlocked_ensure_ram_image(
bool allow_compression);
687 virtual void do_reload_ram_image(CData *cdata,
bool allow_compression);
689 PTA_uchar do_modify_ram_image(CData *cdata);
690 PTA_uchar do_make_ram_image(CData *cdata);
691 void do_set_ram_image(CData *cdata,
CPTA_uchar image,
692 CompressionMode compression = CM_off,
size_t page_size = 0);
693 PTA_uchar do_modify_ram_mipmap_image(CData *cdata,
int n);
694 PTA_uchar do_make_ram_mipmap_image(CData *cdata,
int n);
695 void do_set_ram_mipmap_image(CData *cdata,
int n,
CPTA_uchar image,
size_t page_size);
696 size_t do_get_clear_data(
const CData *cdata,
unsigned char *into)
const;
698 bool consider_auto_process_ram_image(
bool generate_mipmaps,
bool allow_compression);
699 bool do_consider_auto_process_ram_image(CData *cdata,
bool generate_mipmaps,
700 bool allow_compression);
701 bool do_compress_ram_image(CData *cdata, CompressionMode compression,
702 QualityLevel quality_level,
704 bool do_uncompress_ram_image(CData *cdata);
706 static void do_compress_ram_image_bc4(
const RamImage &src, RamImage &dest,
707 int x_size,
int y_size,
int z_size);
708 static void do_compress_ram_image_bc5(
const RamImage &src, RamImage &dest,
709 int x_size,
int y_size,
int z_size);
710 static void do_uncompress_ram_image_bc4(
const RamImage &src, RamImage &dest,
711 int x_size,
int y_size,
int z_size);
712 static void do_uncompress_ram_image_bc5(
const RamImage &src, RamImage &dest,
713 int x_size,
int y_size,
int z_size);
714 bool do_has_all_ram_mipmap_images(
const CData *cdata)
const;
716 bool do_reconsider_z_size(CData *cdata,
int z,
const LoaderOptions &options);
717 virtual void do_allocate_pages(CData *cdata);
718 bool do_reconsider_image_properties(CData *cdata,
719 int x_size,
int y_size,
int num_components,
720 ComponentType component_type,
int z,
722 bool do_rescale_texture(CData *cdata);
724 virtual PT(
Texture) make_copy_impl()
const;
725 PT(
Texture) do_make_copy(
const CData *cdata)
const;
726 void do_assign(CData *cdata,
const Texture *copy,
const CData *cdata_copy);
727 virtual void do_clear(CData *cdata);
728 void do_setup_texture(CData *cdata,
729 TextureType texture_type,
int x_size,
int y_size,
730 int z_size, ComponentType component_type,
732 void do_set_num_views(CData *cdata,
int num_views);
733 void do_set_format(CData *cdata, Format format);
734 void do_set_component_type(CData *cdata, ComponentType component_type);
735 void do_set_x_size(CData *cdata,
int x_size);
736 void do_set_y_size(CData *cdata,
int y_size);
737 void do_set_z_size(CData *cdata,
int z_size);
739 void do_set_wrap_u(CData *cdata, WrapMode wrap);
740 void do_set_wrap_v(CData *cdata, WrapMode wrap);
741 void do_set_wrap_w(CData *cdata, WrapMode wrap);
742 void do_set_minfilter(CData *cdata, FilterType filter);
743 void do_set_magfilter(CData *cdata, FilterType filter);
744 void do_set_anisotropic_degree(CData *cdata,
int anisotropic_degree);
745 void do_set_border_color(CData *cdata,
const LColor &color);
746 void do_set_compression(CData *cdata, CompressionMode compression);
747 void do_set_quality_level(CData *cdata, QualityLevel quality_level);
749 bool do_has_compression(
const CData *cdata)
const;
750 virtual bool do_has_ram_image(
const CData *cdata)
const;
751 virtual bool do_has_uncompressed_ram_image(
const CData *cdata)
const;
753 CPTA_uchar do_get_uncompressed_ram_image(CData *cdata);
754 void do_set_simple_ram_image(CData *cdata,
CPTA_uchar image,
int x_size,
int y_size);
755 INLINE
size_t do_get_ram_image_size(
const CData *cdata)
const;
756 INLINE
bool do_has_ram_mipmap_image(
const CData *cdata,
int n)
const;
757 int do_get_expected_num_mipmap_levels(
const CData *cdata)
const;
758 INLINE
size_t do_get_expected_ram_image_size(
const CData *cdata)
const;
759 INLINE
size_t do_get_expected_ram_view_size(
const CData *cdata)
const;
760 INLINE
size_t do_get_expected_ram_page_size(
const CData *cdata)
const;
761 size_t do_get_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
762 INLINE
size_t do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const;
763 INLINE
size_t do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const;
764 INLINE
size_t do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
765 int do_get_expected_mipmap_x_size(
const CData *cdata,
int n)
const;
766 int do_get_expected_mipmap_y_size(
const CData *cdata,
int n)
const;
767 int do_get_expected_mipmap_z_size(
const CData *cdata,
int n)
const;
768 INLINE
int do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const;
769 INLINE
void do_clear_ram_image(CData *cdata);
770 void do_clear_simple_ram_image(CData *cdata);
771 void do_clear_ram_mipmap_images(CData *cdata);
772 void do_generate_ram_mipmap_images(CData *cdata,
bool allow_recompress);
773 void do_set_pad_size(CData *cdata,
int x,
int y,
int z);
774 virtual bool do_can_reload(
const CData *cdata)
const;
775 bool do_reload(CData *cdata);
777 INLINE AutoTextureScale do_get_auto_texture_scale(
const CData *cdata)
const;
779 virtual bool do_has_bam_rawdata(
const CData *cdata)
const;
780 virtual void do_get_bam_rawdata(CData *cdata);
792 void *_pointer_image;
796 static void convert_from_pnmimage(PTA_uchar &image,
size_t page_size,
797 int row_stride,
int x,
int y,
int z,
799 int num_components,
int component_width);
800 static void convert_from_pfm(PTA_uchar &image,
size_t page_size,
802 int num_components,
int component_width);
803 static bool convert_to_pnmimage(
PNMImage &pnmimage,
int x_size,
int y_size,
805 ComponentType component_type,
bool is_srgb,
808 static bool convert_to_pfm(
PfmFile &pfm,
int x_size,
int y_size,
809 int num_components,
int component_width,
812 static PTA_uchar read_dds_level_bgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
813 int n, std::istream &in);
814 static PTA_uchar read_dds_level_rgb8(
Texture *tex, CData *cdata,
const DDSHeader &header,
815 int n, std::istream &in);
816 static PTA_uchar read_dds_level_abgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
817 int n, std::istream &in);
818 static PTA_uchar read_dds_level_rgba8(
Texture *tex, CData *cdata,
const DDSHeader &header,
819 int n, std::istream &in);
820 static PTA_uchar read_dds_level_abgr16(
Texture *tex, CData *cdata,
const DDSHeader &header,
821 int n, std::istream &in);
822 static PTA_uchar read_dds_level_abgr32(
Texture *tex, CData *cdata,
const DDSHeader &header,
823 int n, std::istream &in);
824 static PTA_uchar read_dds_level_raw(
Texture *tex, CData *cdata,
const DDSHeader &header,
825 int n, std::istream &in);
826 static PTA_uchar read_dds_level_generic_uncompressed(
Texture *tex, CData *cdata,
827 const DDSHeader &header,
828 int n, std::istream &in);
829 static PTA_uchar read_dds_level_luminance_uncompressed(
Texture *tex, CData *cdata,
830 const DDSHeader &header,
831 int n, std::istream &in);
832 static PTA_uchar read_dds_level_bc1(
Texture *tex, CData *cdata,
833 const DDSHeader &header,
834 int n, std::istream &in);
835 static PTA_uchar read_dds_level_bc2(
Texture *tex, CData *cdata,
836 const DDSHeader &header,
837 int n, std::istream &in);
838 static PTA_uchar read_dds_level_bc3(
Texture *tex, CData *cdata,
839 const DDSHeader &header,
840 int n, std::istream &in);
841 static PTA_uchar read_dds_level_bc4(
Texture *tex, CData *cdata,
842 const DDSHeader &header,
843 int n, std::istream &in);
844 static PTA_uchar read_dds_level_bc5(
Texture *tex, CData *cdata,
845 const DDSHeader &header,
846 int n, std::istream &in);
850 static void consider_downgrade(
PNMImage &pnmimage,
int num_channels,
const std::string &name);
854 INLINE
static void store_unscaled_byte(
unsigned char *&p,
int value);
855 INLINE
static void store_unscaled_short(
unsigned char *&p,
int value);
856 INLINE
static void store_scaled_byte(
unsigned char *&p,
int value,
double scale);
857 INLINE
static void store_scaled_short(
unsigned char *&p,
int value,
double scale);
858 INLINE
static double get_unsigned_byte(
const unsigned char *&p);
859 INLINE
static double get_unsigned_short(
const unsigned char *&p);
860 INLINE
static double get_unsigned_int(
const unsigned char *&p);
861 INLINE
static double get_unsigned_int_24(
const unsigned char *&p);
862 INLINE
static double get_float(
const unsigned char *&p);
863 INLINE
static double get_half_float(
const unsigned char *&p);
865 INLINE
static bool is_txo_filename(
const Filename &fullpath);
866 INLINE
static bool is_dds_filename(
const Filename &fullpath);
867 INLINE
static bool is_ktx_filename(
const Filename &fullpath);
869 void do_filter_2d_mipmap_pages(
const CData *cdata,
870 RamImage &to,
const RamImage &from,
871 int x_size,
int y_size)
const;
873 void do_filter_3d_mipmap_level(
const CData *cdata,
874 RamImage &to,
const RamImage &from,
875 int x_size,
int y_size,
int z_size)
const;
877 typedef void Filter2DComponent(
unsigned char *&p,
878 const unsigned char *&q,
879 size_t pixel_size,
size_t row_size);
881 typedef void Filter3DComponent(
unsigned char *&p,
882 const unsigned char *&q,
883 size_t pixel_size,
size_t row_size,
886 static void filter_2d_unsigned_byte(
unsigned char *&p,
887 const unsigned char *&q,
888 size_t pixel_size,
size_t row_size);
889 static void filter_2d_unsigned_byte_srgb(
unsigned char *&p,
890 const unsigned char *&q,
891 size_t pixel_size,
size_t row_size);
892 static void filter_2d_unsigned_byte_srgb_sse2(
unsigned char *&p,
893 const unsigned char *&q,
894 size_t pixel_size,
size_t row_size);
895 static void filter_2d_unsigned_short(
unsigned char *&p,
896 const unsigned char *&q,
897 size_t pixel_size,
size_t row_size);
898 static void filter_2d_float(
unsigned char *&p,
const unsigned char *&q,
899 size_t pixel_size,
size_t row_size);
901 static void filter_3d_unsigned_byte(
unsigned char *&p,
902 const unsigned char *&q,
903 size_t pixel_size,
size_t row_size,
905 static void filter_3d_unsigned_byte_srgb(
unsigned char *&p,
906 const unsigned char *&q,
907 size_t pixel_size,
size_t row_size,
909 static void filter_3d_unsigned_byte_srgb_sse2(
unsigned char *&p,
910 const unsigned char *&q,
911 size_t pixel_size,
size_t row_size,
913 static void filter_3d_unsigned_short(
unsigned char *&p,
914 const unsigned char *&q,
915 size_t pixel_size,
size_t row_size,
917 static void filter_3d_float(
unsigned char *&p,
const unsigned char *&q,
918 size_t pixel_size,
size_t row_size,
size_t page_size);
920 bool do_squish(CData *cdata, CompressionMode compression,
int squish_flags);
921 bool do_unsquish(CData *cdata,
int squish_flags);
927 class EXPCL_PANDA_GOBJ CData :
public CycleData {
930 CData(
const CData ©);
931 ALLOC_DELETED_CHAIN(CData);
937 return Texture::get_class_type();
940 void do_assign(
const CData *copy);
941 INLINE
void inc_properties_modified();
942 INLINE
void inc_image_modified();
943 INLINE
void inc_simple_image_modified();
951 int _primary_file_num_channels;
956 int _alpha_file_channel;
963 int _component_width;
964 TextureType _texture_type;
966 ComponentType _component_type;
967 GeomEnums::UsageHint _usage_hint;
969 bool _loaded_from_image;
970 bool _loaded_from_txo;
971 bool _has_read_pages;
972 bool _has_read_mipmaps;
973 int _num_mipmap_levels_read;
976 bool _keep_ram_image;
977 LColor _border_color;
978 CompressionMode _compression;
979 bool _render_to_texture;
980 bool _match_framebuffer_format;
981 bool _post_load_store_cache;
982 QualityLevel _quality_level;
988 int _orig_file_x_size;
989 int _orig_file_y_size;
991 AutoTextureScale _auto_texture_scale;
992 CompressionMode _ram_image_compression;
997 RamImages _ram_images;
1001 RamImage _simple_ram_image;
1004 int32_t _simple_image_date_generated;
1007 bool _has_clear_color;
1008 LColor _clear_color;
1016 return _type_handle;
1018 static void init_type() {
1047 PreparedViews _prepared_views;
1055 RelatedTextures _related_textures;
1065 static AutoTextureScale _textures_power_2;
1070 static void register_with_read_factory();
1073 virtual void finalize(
BamReader *manager);
1076 void do_write_datagram_header(CData *cdata,
BamWriter *manager,
Datagram &me,
bool &has_rawdata);
1077 virtual void do_write_datagram_body(CData *cdata,
BamWriter *manager,
Datagram &me);
1078 virtual void do_write_datagram_rawdata(CData *cdata,
BamWriter *manager,
Datagram &me);
1083 virtual void do_fillin_from(CData *cdata,
const Texture *dummy);
1087 return _type_handle;
1089 static void init_type() {
1090 TypedWritableReferenceCount::init_type();
1092 TypedWritableReferenceCount::get_class_type());
1096 return get_class_type();
1098 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
1112 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::TextureType tt);
1113 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::ComponentType ct);
1114 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::Format f);
1116 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::CompressionMode cm);
1117 EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::QualityLevel tql);
1118 EXPCL_PANDA_GOBJ std::istream &operator >> (std::istream &in, Texture::QualityLevel &tql);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL map.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Specifies parameters that may be passed to the loader.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
A single page of data maintained by a PipelineCycler.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Base class for objects that can be written to and read from Bam files.
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.
This is a special class object that holds all the information returned by a particular GSG to indicat...
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
A standard mutex, or mutual exclusion lock.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is our own Panda specialization on the default STL list.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A table of objects that are saved within the graphics context for reference by handle later.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that represents a single element that may be timed and/or counted via stats.
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
A base class for all things which can have a name.
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,...
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
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.
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class specializes ConfigVariable as an enumerated type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Encodes a string name in a hash table, mapping it to a pointer.
An instance of this object is returned by Texture::peek().
Represents a set of settings that indicate how a texture is sampled.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
This class implements a condition variable; see ConditionVar for a brief introduction to this class.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the preferred interface for loading textures from image files.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...