diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index bf3614708f..be568fee9a 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -314,15 +314,19 @@ add_render_texture(Texture *tex, RenderTextureMode mode, // which has system-imposed restrictions on size). tex->set_size_padded(get_x_size(), get_y_size()); - if (mode == RTM_bind_or_copy && !support_render_texture) { - mode = RTM_copy_texture; - } - else { - if (_gsg -> get_supports_render_texture ( )) { - tex->set_render_to_texture (true); + if (mode == RTM_bind_or_copy) { + if (!_gsg->get_supports_render_texture() || !support_render_texture) { + // Binding is not supported or it is disabled, so just fall back + // to copy instead. + mode = RTM_copy_texture; } } + if (mode == RTM_bind_or_copy) { + // If we're still planning on binding, indicate it in texture + // properly. + tex->set_render_to_texture(true); + } RenderTexture result; result._texture = tex; diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 1e8c97e08e..5a4b99d108 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -720,7 +720,15 @@ get_compression() const { //////////////////////////////////////////////////////////////////// // Function: Texture::get_render_to_texture // Access: Published -// Description: +// Description: Returns a flag on the texture that indicates whether the +// texture is intended to be used as a direct-render +// target, by binding a framebuffer to a texture and +// rendering directly into the texture. +// +// Normally, a user should not need to set this flag +// directly; it is set automatically by the low-level +// display code when a texture is bound to a +// framebuffer. //////////////////////////////////////////////////////////////////// INLINE bool Texture:: get_render_to_texture() const { diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 0864581c54..4ea1685e2d 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -840,7 +840,19 @@ set_compression(Texture::CompressionMode compression) { //////////////////////////////////////////////////////////////////// // Function: Texture::set_render_to_texture // Access: Published -// Description: +// Description: Sets a flag on the texture that indicates whether the +// texture is intended to be used as a direct-render +// target, by binding a framebuffer to a texture and +// rendering directly into the texture. +// +// This controls some low-level choices made about the +// texture object itself. For instance, compressed +// textures are disallowed when this flag is set true. +// +// Normally, a user should not need to set this flag +// directly; it is set automatically by the low-level +// display code when a texture is bound to a +// framebuffer. //////////////////////////////////////////////////////////////////// void Texture:: set_render_to_texture(bool render_to_texture) { diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx index 9b8f01ba61..136b8cf97b 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx @@ -118,7 +118,7 @@ close_buffer() { _active = false; } - GraphicsBuffer::close_buffer(); + _is_valid = false; } ////////////////////////////////////////////////////////////////////