From 5cadd86d1edf86182347d4d14b6f95cf108aa57c Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 5 Mar 2021 11:57:05 +0100 Subject: [PATCH] glgsg: Fix get_screenshot() for multisample FBOs An FM_refresh bind should not bind the multisample FBO, but the resolved one (and while we're at it, FM_refresh should not try to resolve multisamples). --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index d484a174e4..7413fef56e 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -283,6 +283,12 @@ begin_frame(FrameMode mode, Thread *current_thread) { } else if (mode == FM_refresh) { // Just bind the FBO. rebuild_bitplanes(); + + // Bind the non-multisample FBO, since we won't be rendering anything and + // the caller probably wanted to grab a screenshot. + if (_fbo_multisample != 0 && !_fbo.empty()) { + glgsg->bind_fbo(_fbo[0]); + } } // The host window may not have had sRGB enabled, so we need to do this. @@ -1330,11 +1336,12 @@ end_frame(FrameMode mode, Thread *current_thread) { nassertv(_gsg != nullptr); // Resolve Multisample rendering if using it. - if (_requested_multisamples && _fbo_multisample) { + if (_requested_multisamples && _fbo_multisample && mode != FM_refresh) { resolve_multisamples(); } if (mode == FM_render) { + // Should happen *after* resolving multisamples, with the non-MS FBO bound. copy_to_textures(); }