mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
fix render-to-texture issue
This commit is contained in:
parent
5545aa6ce7
commit
a019d736ec
@ -591,8 +591,7 @@ get_active_display_region(int n) const {
|
|||||||
// Description: Generates a GeomVertexData for a texture card.
|
// Description: Generates a GeomVertexData for a texture card.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PT(GeomVertexData) GraphicsOutput::
|
PT(GeomVertexData) GraphicsOutput::
|
||||||
create_texture_card_vdata(int x, int y)
|
create_texture_card_vdata(int x, int y) {
|
||||||
{
|
|
||||||
float xhi = 1.0;
|
float xhi = 1.0;
|
||||||
float yhi = 1.0;
|
float yhi = 1.0;
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ set_size(int x, int y) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void ParasiteBuffer::
|
void ParasiteBuffer::
|
||||||
set_size_and_recalc(int x, int y) {
|
set_size_and_recalc(int x, int y) {
|
||||||
|
if (!(_creation_flags & GraphicsPipe::BF_size_track_host)) {
|
||||||
if (_creation_flags & GraphicsPipe::BF_size_power_2) {
|
if (_creation_flags & GraphicsPipe::BF_size_power_2) {
|
||||||
x = Texture::down_to_power_2(x);
|
x = Texture::down_to_power_2(x);
|
||||||
y = Texture::down_to_power_2(y);
|
y = Texture::down_to_power_2(y);
|
||||||
@ -99,6 +100,7 @@ set_size_and_recalc(int x, int y) {
|
|||||||
if (_creation_flags & GraphicsPipe::BF_size_square) {
|
if (_creation_flags & GraphicsPipe::BF_size_square) {
|
||||||
x = y = min(x, y);
|
x = y = min(x, y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsOutput::set_size_and_recalc(x, y);
|
GraphicsOutput::set_size_and_recalc(x, y);
|
||||||
}
|
}
|
||||||
|
@ -3442,6 +3442,8 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
|||||||
|
|
||||||
GLenum target = get_texture_target(tex->get_texture_type());
|
GLenum target = get_texture_target(tex->get_texture_type());
|
||||||
GLint internal_format = get_internal_image_format(tex);
|
GLint internal_format = get_internal_image_format(tex);
|
||||||
|
int width = tex->get_x_size();
|
||||||
|
int height = tex->get_y_size();
|
||||||
|
|
||||||
bool uses_mipmaps = tex->uses_mipmaps() && !CLP(ignore_mipmaps);
|
bool uses_mipmaps = tex->uses_mipmaps() && !CLP(ignore_mipmaps);
|
||||||
if (uses_mipmaps) {
|
if (uses_mipmaps) {
|
||||||
@ -3455,8 +3457,13 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool new_image = needs_reload || gtc->was_image_modified();
|
bool new_image = needs_reload || gtc->was_image_modified();
|
||||||
if (internal_format != gtc->_internal_format) {
|
if (!gtc->_already_applied ||
|
||||||
// If the internal format has changed, we need to reload the
|
internal_format != gtc->_internal_format ||
|
||||||
|
uses_mipmaps != gtc->_uses_mipmaps ||
|
||||||
|
width != gtc->_width ||
|
||||||
|
height != gtc->_height ||
|
||||||
|
1 != gtc->_depth) {
|
||||||
|
// If the texture properties have changed, we need to reload the
|
||||||
// image.
|
// image.
|
||||||
new_image = true;
|
new_image = true;
|
||||||
}
|
}
|
||||||
@ -3471,12 +3478,29 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
|||||||
|
|
||||||
if (new_image) {
|
if (new_image) {
|
||||||
// We have to create a new image.
|
// We have to create a new image.
|
||||||
|
if (w != width || h != height) {
|
||||||
|
// This means a two-step process, to create a texture of the
|
||||||
|
// appropriate size.
|
||||||
|
GLP(TexImage2D)(target, 0, internal_format, width, height, 0,
|
||||||
|
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
GLP(CopyTexSubImage2D)(target, 0, 0, 0, xo, yo, w, h);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// One-step process.
|
||||||
GLP(CopyTexImage2D)(target, 0, internal_format, xo, yo, w, h, 0);
|
GLP(CopyTexImage2D)(target, 0, internal_format, xo, yo, w, h, 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// We can overlay the existing image.
|
// We can overlay the existing image.
|
||||||
GLP(CopyTexSubImage2D)(target, 0, 0, 0, xo, yo, w, h);
|
GLP(CopyTexSubImage2D)(target, 0, 0, 0, xo, yo, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtc->_already_applied = true;
|
||||||
|
gtc->_uses_mipmaps = uses_mipmaps;
|
||||||
|
gtc->_internal_format = internal_format;
|
||||||
|
gtc->_width = width;
|
||||||
|
gtc->_height = height;
|
||||||
|
gtc->_depth = 1;
|
||||||
|
|
||||||
gtc->mark_loaded();
|
gtc->mark_loaded();
|
||||||
gtc->enqueue_lru(&_prepared_objects->_graphics_memory_lru);
|
gtc->enqueue_lru(&_prepared_objects->_graphics_memory_lru);
|
||||||
|
|
||||||
|
@ -24,4 +24,9 @@ CLP(TextureContext)(PreparedGraphicsObjects *pgo, Texture *tex) :
|
|||||||
{
|
{
|
||||||
_index = 0;
|
_index = 0;
|
||||||
_already_applied = false;
|
_already_applied = false;
|
||||||
|
_uses_mipmaps = false;
|
||||||
|
_internal_format = 0;
|
||||||
|
_width = 0;
|
||||||
|
_height = 0;
|
||||||
|
_depth = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user