diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index a6673988c8..c3c6dd0fb4 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -2005,27 +2005,7 @@ resolve_multisamples() { } } -#ifndef OPENGLES - if (_have_any_color) { - glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); - glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); - } else { - glDrawBuffer(GL_NONE); - glReadBuffer(GL_NONE); - } -#endif - - if (do_depth_blit) { - glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y, - GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, - GL_NEAREST); - } - else if (_have_any_color) { - glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y, - GL_COLOR_BUFFER_BIT, - GL_NEAREST); - } - // Now handle the other color buffers. + // First handle the auxiliary buffers. #ifndef OPENGLES int next = GL_COLOR_ATTACHMENT1_EXT; if (_fb_properties.is_stereo()) { @@ -2057,11 +2037,9 @@ resolve_multisamples() { next += 1; } #endif - report_my_gl_errors(); - - // Bind the regular FBO as read buffer for the sake of copy_to_textures. - glgsg->_glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, fbo); + // Now blit the normal color target, plus any depth/stencil. + // We do this last because we want to leave attachment 0 bound at the end. #ifndef OPENGLES if (_have_any_color) { glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); @@ -2071,5 +2049,20 @@ resolve_multisamples() { glReadBuffer(GL_NONE); } #endif + + if (do_depth_blit) { + glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y, + GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, + GL_NEAREST); + } + else if (_have_any_color) { + glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y, + GL_COLOR_BUFFER_BIT, + GL_NEAREST); + } + + // Bind the regular FBO as read buffer for the sake of copy_to_textures. + glgsg->_glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, fbo); + report_my_gl_errors(); }