Browse Source

fix RTM_bind_or_copy

David Rose 17 years ago
parent
commit
6e72268787

+ 10 - 6
panda/src/display/graphicsOutput.cxx

@@ -314,15 +314,19 @@ add_render_texture(Texture *tex, RenderTextureMode mode,
   // which has system-imposed restrictions on size).
   // which has system-imposed restrictions on size).
   tex->set_size_padded(get_x_size(), get_y_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;
   RenderTexture result;
   result._texture = tex;
   result._texture = tex;

+ 9 - 1
panda/src/gobj/texture.I

@@ -720,7 +720,15 @@ get_compression() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Texture::get_render_to_texture
 //     Function: Texture::get_render_to_texture
 //       Access: Published
 //       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::
 INLINE bool Texture::
 get_render_to_texture() const {
 get_render_to_texture() const {

+ 13 - 1
panda/src/gobj/texture.cxx

@@ -840,7 +840,19 @@ set_compression(Texture::CompressionMode compression) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Texture::set_render_to_texture
 //     Function: Texture::set_render_to_texture
 //       Access: Published
 //       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::
 void Texture::
 set_render_to_texture(bool render_to_texture) {
 set_render_to_texture(bool render_to_texture) {

+ 1 - 1
panda/src/tinydisplay/tinyGraphicsBuffer.cxx

@@ -118,7 +118,7 @@ close_buffer() {
     _active = false;
     _active = false;
   }
   }
 
 
-  GraphicsBuffer::close_buffer();
+  _is_valid = false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////