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

This commit is contained in:
rdb 2019-12-18 18:01:42 +01:00
parent a57df32037
commit 3c3eee2295
3 changed files with 11 additions and 7 deletions

View File

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

View File

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

View File

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