restore opts['viewport'] after clobbering

This commit is contained in:
KIU Shueng Chuan 2021-07-17 16:14:25 +08:00
parent dfd5b5dc1b
commit 7a17cda956

View File

@ -550,6 +550,7 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, texwidth, texwidth) glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, texwidth, texwidth)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_buf) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_buf)
viewport_orig = self.opts['viewport']
self.opts['viewport'] = (0, 0, w, h) # viewport is the complete image; this ensures that paintGL(region=...) self.opts['viewport'] = (0, 0, w, h) # viewport is the complete image; this ensures that paintGL(region=...)
# is interpreted correctly. # is interpreted correctly.
p2 = 2 * padding p2 = 2 * padding
@ -572,7 +573,7 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
output[x+padding:x2-padding, y+padding:y2-padding] = data[padding:w2-padding, -(h2-padding):-padding] output[x+padding:x2-padding, y+padding:y2-padding] = data[padding:w2-padding, -(h2-padding):-padding]
finally: finally:
self.opts['viewport'] = None self.opts['viewport'] = viewport_orig
glfbo.glBindFramebuffer(glfbo.GL_FRAMEBUFFER, 0) glfbo.glBindFramebuffer(glfbo.GL_FRAMEBUFFER, 0)
glBindTexture(GL_TEXTURE_2D, 0) glBindTexture(GL_TEXTURE_2D, 0)
if tex is not None: if tex is not None: