Browse Source

glgsg: Fix clear of offscreen buffer if back buffers requested

rdb 1 year ago
parent
commit
122453811d
1 changed files with 13 additions and 1 deletions
  1. 13 1
      panda/src/glstuff/glGraphicsBuffer_src.cxx

+ 13 - 1
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"),