Browse Source

glgsg: attempt to fix stereo FBOs in OpenGL ES 2 (#815)

rdb 6 years ago
parent
commit
3c3eee2295

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

@@ -84,7 +84,7 @@ CLP(GraphicsBuffer)::
   }
 }
 
-#ifndef OPENGLES
+#ifndef OPENGLES_1
 /**
  * Clears the entire framebuffer before rendering, according to the settings
  * of get_color_clear_active() and get_depth_clear_active() (inherited from
@@ -587,7 +587,6 @@ rebuild_bitplanes() {
       _have_any_color = true;
     }
 
-#ifndef OPENGLES_1
     for (int i=0; i<_fb_properties.get_aux_rgba(); i++) {
       bind_slot(layer, rb_resize, attach, (RenderTexturePlane)(RTP_aux_rgba_0+i), next++);
       _have_any_color = true;
@@ -600,7 +599,6 @@ rebuild_bitplanes() {
       bind_slot(layer, rb_resize, attach, (RenderTexturePlane)(RTP_aux_float_0+i), next++);
       _have_any_color = true;
     }
-#endif  // OPENGLES
 
     if (_have_any_color || have_any_depth) {
       // Clear if the fbo was just created, regardless of the clear settings per

+ 1 - 1
panda/src/glstuff/glGraphicsBuffer_src.h

@@ -58,7 +58,7 @@ public:
                       GraphicsOutput *host);
   virtual ~CLP(GraphicsBuffer)();
 
-#ifndef OPENGLES
+#ifndef OPENGLES_1
   virtual void clear(Thread *current_thread);
 #endif
   virtual bool begin_frame(FrameMode mode, Thread *current_thread);

+ 9 - 3
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -8960,7 +8960,7 @@ do_get_extension_func(const char *) {
  */
 void CLP(GraphicsStateGuardian)::
 set_draw_buffer(int rbtype) {
-#ifndef OPENGLES  // Draw buffers not supported by OpenGL ES. (TODO!)
+#ifndef OPENGLES_1  // Draw buffers not supported by OpenGL ES 1.
   if (_current_fbo) {
     GLuint buffers[16];
     int nbuffers = 0;
@@ -8995,9 +8995,14 @@ set_draw_buffer(int rbtype) {
       }
       ++index;
     }
-    _glDrawBuffers(nbuffers, buffers);
+    if (_glDrawBuffers != nullptr) {
+      _glDrawBuffers(nbuffers, buffers);
+    } else {
+      nassertv(nbuffers == 1 && buffers[0] == GL_COLOR_ATTACHMENT0_EXT);
+    }
 
   } else {
+#ifndef OPENGLES
     switch (rbtype & RenderBuffer::T_color) {
     case RenderBuffer::T_front:
       glDrawBuffer(GL_FRONT);
@@ -9038,8 +9043,9 @@ set_draw_buffer(int rbtype) {
     default:
       break;
     }
-  }
 #endif  // OPENGLES
+  }
+#endif  // OPENGLES_1
 
   // Also ensure that any global color channels are masked out.
   set_color_write_mask(_color_write_mask);