From 3c3eee22955d80824d2daa366e24ac25c1ad70ce Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 18 Dec 2019 18:01:42 +0100 Subject: [PATCH] glgsg: attempt to fix stereo FBOs in OpenGL ES 2 (#815) --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 4 +--- panda/src/glstuff/glGraphicsBuffer_src.h | 2 +- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 12 +++++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index d484a174e4..ebabce3908 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/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 diff --git a/panda/src/glstuff/glGraphicsBuffer_src.h b/panda/src/glstuff/glGraphicsBuffer_src.h index c383a0a5d4..0253cb0c89 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.h +++ b/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); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 631968808f..8d8b14d87c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/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);