From 122453811d917b16e60e75f0de47b18e37c4dd7a Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 30 Jun 2024 11:53:17 +0200 Subject: [PATCH] glgsg: Fix clear of offscreen buffer if back buffers requested --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index b66be51b3c..e63ea89b17 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -16,6 +16,18 @@ using std::max; using std::min; +/** + * Returns a copy of the FrameBufferProperties, but without back buffers. + * This is used since the GraphicsOutput constructor makes some decisions + * based on whether this is set, so we need to unset it early. + */ +static FrameBufferProperties +without_back_buffers(const FrameBufferProperties &fb_prop) { + FrameBufferProperties copy(fb_prop); + copy.set_back_buffers(0); + return copy; +} + TypeHandle CLP(GraphicsBuffer)::_type_handle; /** @@ -29,7 +41,7 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, int flags, GraphicsStateGuardian *gsg, GraphicsOutput *host) : - GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host), + GraphicsBuffer(engine, pipe, name, without_back_buffers(fb_prop), win_prop, flags, gsg, host), _bind_texture_pcollector(_draw_window_pcollector, "Bind textures"), _generate_mipmap_pcollector(_draw_window_pcollector, "Generate mipmaps"), _resolve_multisample_pcollector(_draw_window_pcollector, "Resolve multisamples"),