RawImageWidget.py : fix port to QOpenGLWidget

Qt5 docs specify differences between QGLWidget and QOpenGLWidget:
"...when invoking paintGL().
 QOpenGLWidget sets up the viewport via glViewport().
 It does not perform any clearing."
This commit is contained in:
KIU Shueng Chuan 2021-02-16 09:15:37 +08:00
parent 6519734932
commit 2719922584

View File

@ -134,6 +134,8 @@ if HAVE_OPENGL:
glDisable(GL_TEXTURE_2D)
def paintGL(self):
glClear(GL_COLOR_BUFFER_BIT)
if self.image is None:
if self.opts is None:
return
@ -144,9 +146,6 @@ if HAVE_OPENGL:
if not self.uploaded:
self.uploadTexture()
dpr = self.devicePixelRatio()
vp = (0, 0, int(self.width() * dpr), int(self.height() * dpr))
glViewport(*vp)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, self.texture)
glColor4f(1, 1, 1, 1)