فهرست منبع

glgsg: add ability to get red/rg-only floating-point renderbuffers

rdb 7 سال پیش
والد
کامیت
11526852ed
1فایلهای تغییر یافته به همراه27 افزوده شده و 10 حذف شده
  1. 27 10
      panda/src/glstuff/glGraphicsBuffer_src.cxx

+ 27 - 10
panda/src/glstuff/glGraphicsBuffer_src.cxx

@@ -921,20 +921,37 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
         if (_fb_properties.get_alpha_bits() == 0) {
           if (_fb_properties.get_srgb_color()) {
             gl_format = GL_SRGB8;
-          } else if (_fb_properties.get_float_color()) {
-            if (_fb_properties.get_color_bits() > 16 * 3) {
-              gl_format = GL_RGB32F_ARB;
+          } else if (_fb_properties.get_color_bits() > 16 * 3 ||
+                     _fb_properties.get_red_bits() > 16 ||
+                     _fb_properties.get_green_bits() > 16 ||
+                     _fb_properties.get_blue_bits() > 16) {
+            // 32-bit, which is always floating-point.
+            if (_fb_properties.get_blue_bits() > 0 ||
+                _fb_properties.get_color_bits() == 1 ||
+                _fb_properties.get_color_bits() > 32 * 2) {
+              gl_format = GL_RGB32F;
+            } else if (_fb_properties.get_green_bits() > 0 ||
+                       _fb_properties.get_color_bits() > 32) {
+              gl_format = GL_RG32F;
             } else {
-              gl_format = GL_RGB16F_ARB;
+              gl_format = GL_R32F;
             }
-          } else {
-            if (_fb_properties.get_color_bits() > 16 * 3) {
-              gl_format = GL_RGB32F_ARB;
-            } else if (_fb_properties.get_color_bits() > 8 * 3) {
-              gl_format = GL_RGB16_EXT;
+          } else if (_fb_properties.get_float_color()) {
+            // 16-bit floating-point.
+            if (_fb_properties.get_blue_bits() > 0 ||
+                _fb_properties.get_color_bits() == 1 ||
+                _fb_properties.get_color_bits() > 16 * 2) {
+              gl_format = GL_RGB16F;
+            } else if (_fb_properties.get_green_bits() > 0 ||
+                       _fb_properties.get_color_bits() > 16) {
+              gl_format = GL_RG16F;
             } else {
-              gl_format = GL_RGB;
+              gl_format = GL_R16F;
             }
+          } else if (_fb_properties.get_color_bits() > 8 * 3) {
+            gl_format = GL_RGB16_EXT;
+          } else {
+            gl_format = GL_RGB;
           }
         } else {
           if (_fb_properties.get_srgb_color()) {