Browse Source

glgsg: Fixes to format selection in OpenGL renderbuffers

Fixes #1137
rdb 4 years ago
parent
commit
ab4367ee7b
1 changed files with 21 additions and 3 deletions
  1. 21 3
      panda/src/glstuff/glGraphicsBuffer_src.cxx

+ 21 - 3
panda/src/glstuff/glGraphicsBuffer_src.cxx

@@ -964,8 +964,26 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
             } else {
             } else {
               gl_format = GL_R16F;
               gl_format = GL_R16F;
             }
             }
-          } else if (_fb_properties.get_color_bits() > 8 * 3) {
-            gl_format = GL_RGB16_EXT;
+          } else if (_fb_properties.get_color_bits() > 10 * 3 ||
+                     _fb_properties.get_red_bits() > 10 ||
+                     _fb_properties.get_green_bits() > 10 ||
+                     _fb_properties.get_blue_bits() > 10) {
+            // 16-bit normalized.
+            if (_fb_properties.get_blue_bits() > 0 ||
+                _fb_properties.get_color_bits() == 1 ||
+                _fb_properties.get_color_bits() > 16 * 2) {
+              gl_format = GL_RGBA16;
+            } else if (_fb_properties.get_green_bits() > 0 ||
+                       _fb_properties.get_color_bits() > 16) {
+              gl_format = GL_RG16;
+            } else {
+              gl_format = GL_R16;
+            }
+          } else if (_fb_properties.get_color_bits() > 8 * 3 ||
+                     _fb_properties.get_red_bits() > 8 ||
+                     _fb_properties.get_green_bits() > 8 ||
+                     _fb_properties.get_blue_bits() > 8) {
+            gl_format = GL_RGB10_A2;
           } else {
           } else {
             gl_format = GL_RGB;
             gl_format = GL_RGB;
           }
           }
@@ -982,7 +1000,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
             if (_fb_properties.get_color_bits() > 16 * 3) {
             if (_fb_properties.get_color_bits() > 16 * 3) {
               gl_format = GL_RGBA32F_ARB;
               gl_format = GL_RGBA32F_ARB;
             } else if (_fb_properties.get_color_bits() > 8 * 3) {
             } else if (_fb_properties.get_color_bits() > 8 * 3) {
-              gl_format = GL_RGBA16_EXT;
+              gl_format = GL_RGBA16;
             } else {
             } else {
               gl_format = GL_RGBA;
               gl_format = GL_RGBA;
             }
             }