From c799146cc92ad6f59b34b3a88d6209047e9ce074 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 24 Oct 2022 13:11:27 +0200 Subject: [PATCH] glgsg: Fix stencil renderbuffer not being unbound when binding depth tex Fixes part of #1364 --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 983e7cef23..957f40772a 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -788,6 +788,13 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, GLCAT.debug() << "Binding texture " << *tex << " to depth attachment.\n"; } + if (slot != RTP_depth_stencil && _rb[RTP_depth_stencil] != 0) { + // We have a depth-stencil renderbuffer bound, delete it first. + // This will automatically unbind it as well. + glgsg->_glDeleteRenderbuffers(1, &(_rb[RTP_depth_stencil])); + _rb[RTP_depth_stencil] = 0; + } + attach_tex(layer, 0, tex, GL_DEPTH_ATTACHMENT_EXT); #ifndef OPENGLES