Browse Source

Fix bug: copy-to-ram depth texture binding gets format set to RGB
This was a regression introduced by be8f4de33789cbb96551bb34b1ba85e7134d1e73

Fixes: #212

rdb 8 years ago
parent
commit
29f50be15e

+ 12 - 3
panda/src/display/graphicsOutput.cxx

@@ -275,12 +275,21 @@ add_render_texture(Texture *tex, RenderTextureMode mode,
 
   // Choose a default bitplane.
   if (plane == RTP_COUNT) {
-    if (tex->get_format() == Texture::F_depth_stencil) {
+    switch (tex->get_format()) {
+    case Texture::F_depth_stencil:
       plane = RTP_depth_stencil;
-    } else if (tex->get_format() == Texture::F_depth_component) {
+      break;
+
+    case Texture::F_depth_component:
+    case Texture::F_depth_component16:
+    case Texture::F_depth_component24:
+    case Texture::F_depth_component32:
       plane = RTP_depth;
-    } else {
+      break;
+
+    default:
       plane = RTP_color;
+      break;
     }
   }
 

+ 12 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -6455,6 +6455,18 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z,
     }
     break;
 
+  case Texture::F_depth_component16:
+    component_type = Texture::T_unsigned_short;
+    break;
+
+  case Texture::F_depth_component24:
+    component_type = Texture::T_unsigned_int;
+    break;
+
+  case Texture::F_depth_component32:
+    component_type = Texture::T_float;
+    break;
+
   default:
     if (_current_properties->get_srgb_color()) {
       if (_current_properties->get_alpha_bits()) {