mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 07:48:37 -04:00
gobj: make ram image when writing texture with clear color to 6.44 bam
This makes it possible to write textures with clear colors to .bam files even when the default bam version of 6.44 is selected. The clear color is converted automatically to a filled RAM image. Third part of the fix for #844
This commit is contained in:
parent
707b4fb866
commit
eeeea274a4
@ -10055,11 +10055,31 @@ do_write_datagram_rawdata(CData *cdata, BamWriter *manager, Datagram &me) {
|
||||
me.add_uint8(cdata->_component_type);
|
||||
me.add_uint8(cdata->_component_width);
|
||||
me.add_uint8(cdata->_ram_image_compression);
|
||||
me.add_uint8(cdata->_ram_images.size());
|
||||
for (size_t n = 0; n < cdata->_ram_images.size(); ++n) {
|
||||
me.add_uint32(cdata->_ram_images[n]._page_size);
|
||||
me.add_uint32(cdata->_ram_images[n]._image.size());
|
||||
me.append_data(cdata->_ram_images[n]._image, cdata->_ram_images[n]._image.size());
|
||||
|
||||
if (cdata->_ram_images.empty() && cdata->_has_clear_color &&
|
||||
manager->get_file_minor_ver() < 45) {
|
||||
// For older .bam versions that don't support clear colors, make up a RAM
|
||||
// image.
|
||||
int image_size = do_get_expected_ram_image_size(cdata);
|
||||
me.add_uint8(1);
|
||||
me.add_uint32(do_get_expected_ram_page_size(cdata));
|
||||
me.add_uint32(image_size);
|
||||
|
||||
// Fill the image with the clear color.
|
||||
unsigned char pixel[16];
|
||||
const int pixel_size = do_get_clear_data(cdata, pixel);
|
||||
nassertv(pixel_size > 0);
|
||||
|
||||
for (int i = 0; i < image_size; i += pixel_size) {
|
||||
me.append_data(pixel, pixel_size);
|
||||
}
|
||||
} else {
|
||||
me.add_uint8(cdata->_ram_images.size());
|
||||
for (size_t n = 0; n < cdata->_ram_images.size(); ++n) {
|
||||
me.add_uint32(cdata->_ram_images[n]._page_size);
|
||||
me.add_uint32(cdata->_ram_images[n]._image.size());
|
||||
me.append_data(cdata->_ram_images[n]._image, cdata->_ram_images[n]._image.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user