mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
glgsg: fix issue extracting texture data for multiview textures
This commit is contained in:
parent
cb01d45eb6
commit
2d836697b0
@ -14270,7 +14270,17 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tex->set_ram_image(image, compression, page_size);
|
int num_views = tex->get_num_views();
|
||||||
|
if (num_views == 1) {
|
||||||
|
// Replace the entire image, since we are modifying the only view.
|
||||||
|
tex->set_ram_image(image, compression, page_size);
|
||||||
|
} else {
|
||||||
|
// We're only modifying a single view, so we can't stomp all over the
|
||||||
|
// existing content.
|
||||||
|
PTA_uchar ram_image = tex->modify_ram_image();
|
||||||
|
nassertr(ram_image.size() == image.size() * num_views, false);
|
||||||
|
memcpy(ram_image.p() + image.size() * gtc->get_view(), image.p(), image.size());
|
||||||
|
}
|
||||||
|
|
||||||
if (gtc->_uses_mipmaps) {
|
if (gtc->_uses_mipmaps) {
|
||||||
// Also get the mipmap levels.
|
// Also get the mipmap levels.
|
||||||
@ -14286,7 +14296,12 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
type, compression, n)) {
|
type, compression, n)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tex->set_ram_mipmap_image(n, image, page_size);
|
if (num_views == 1) {
|
||||||
|
tex->set_ram_mipmap_image(n, image, page_size);
|
||||||
|
} else {
|
||||||
|
PTA_uchar ram_mipmap_image = tex->modify_ram_mipmap_image(n);
|
||||||
|
memcpy(ram_mipmap_image.p() + image.size() * gtc->get_view(), image.p(), image.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14350,13 +14365,13 @@ extract_texture_image(PTA_uchar &image, size_t &page_size,
|
|||||||
#ifndef OPENGLES
|
#ifndef OPENGLES
|
||||||
} else if (target == GL_TEXTURE_BUFFER) {
|
} else if (target == GL_TEXTURE_BUFFER) {
|
||||||
// In the case of a buffer texture, we need to get it from the buffer.
|
// In the case of a buffer texture, we need to get it from the buffer.
|
||||||
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_image_size(n));
|
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_view_size(n));
|
||||||
_glGetBufferSubData(target, 0, image.size(), image.p());
|
_glGetBufferSubData(target, 0, image.size(), image.p());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} else if (compression == Texture::CM_off) {
|
} else if (compression == Texture::CM_off) {
|
||||||
// An uncompressed 1-d, 2-d, or 3-d texture.
|
// An uncompressed 1-d, 2-d, or 3-d texture.
|
||||||
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_image_size(n));
|
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_view_size(n));
|
||||||
GLenum external_format = get_external_image_format(tex);
|
GLenum external_format = get_external_image_format(tex);
|
||||||
GLenum pixel_type = get_component_type(type);
|
GLenum pixel_type = get_component_type(type);
|
||||||
glGetTexImage(target, n, external_format, pixel_type, image.p());
|
glGetTexImage(target, n, external_format, pixel_type, image.p());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user