diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-05-17 10:20:25 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-05-17 10:47:41 +0000 |
commit | 7e7d452edde2aba1df4f481bc8ab8df9f219a307 (patch) | |
tree | c9aeefb4a5ae38bf6ca14c3bb8398e11cb9140d8 | |
parent | dfa32dcec82c0916124661788cf527c5bdb68c1c (diff) |
qopenglwindow_test.py: Port to use QtOpenGL functions, only
The test was using a mixture of Qt and Python GL functions,
which can pose problems with Qt's dynamic GL switching on Windows.
Use QtOpenGL functions 1.3, exclusively.
Change-Id: Iecaaacfe3cd8268b6744e5dcdb3c0e0902a148a8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
(cherry picked from commit 8a0a3d7fc64917d53767856f4ecedb636597ec54)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py b/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py index 821281761..d8dede3e0 100644 --- a/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py +++ b/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py @@ -17,7 +17,8 @@ from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QSize, QTimer, Qt from PySide6.QtGui import (QColor, QGuiApplication, QImage, QOpenGLContext, QSurfaceFormat) -from PySide6.QtOpenGL import (QOpenGLTexture, QOpenGLWindow) +from PySide6.QtOpenGL import (QOpenGLTexture, QOpenGLWindow, QOpenGLVersionProfile, + QOpenGLVersionFunctionsFactory) try: @@ -41,36 +42,40 @@ class OpenGLWindow(QOpenGLWindow): self.context().doneCurrent() def initializeGL(self): - self.m_functions = self.context().functions() + profile = QOpenGLVersionProfile() + profile.setVersion(1, 3) + profile.setProfile(QSurfaceFormat.CompatibilityProfile) + self.m_functions = QOpenGLVersionFunctionsFactory.get(profile) self.m_functions.initializeOpenGLFunctions() + print("GL_MAX_LIGHTS=", self.m_functions.glGetIntegerv(GL.GL_MAX_LIGHTS)) image = QImage(QSize(200, 200), QImage.Format_RGBA8888) image.fill(QColor(Qt.red)) self.m_texture = QOpenGLTexture(image) def paintGL(self): - GL.glMatrixMode(GL.GL_MODELVIEW) - GL.glLoadIdentity() + self.m_functions.glMatrixMode(GL.GL_MODELVIEW) + self.m_functions.glLoadIdentity() - GL.glMatrixMode(GL.GL_PROJECTION) - GL.glLoadIdentity() - GL.glOrtho(0, 1, 1, 0, -1, 1) + self.m_functions.glMatrixMode(GL.GL_PROJECTION) + self.m_functions.glLoadIdentity() + self.m_functions.glOrtho(0, 1, 1, 0, -1, 1) self.m_functions.glClear(GL.GL_COLOR_BUFFER_BIT) self.m_functions.glEnable(GL.GL_TEXTURE_2D) self.m_texture.bind() d = 0.5 - GL.glBegin(GL.GL_QUADS) - GL.glTexCoord2f(0, 0) - GL.glVertex2f(0, 0) - GL.glTexCoord2f(d, 0) - GL.glVertex2f(d, 0) - GL.glTexCoord2f(d, d) - GL.glVertex2f(d, d) - GL.glTexCoord2f(0, d) - GL.glVertex2f(0, d) - GL.glEnd() + self.m_functions.glBegin(GL.GL_QUADS) + self.m_functions.glTexCoord2f(0, 0) + self.m_functions.glVertex2f(0, 0) + self.m_functions.glTexCoord2f(d, 0) + self.m_functions.glVertex2f(d, 0) + self.m_functions.glTexCoord2f(d, d) + self.m_functions.glVertex2f(d, d) + self.m_functions.glTexCoord2f(0, d) + self.m_functions.glVertex2f(0, d) + self.m_functions.glEnd() self.m_texture.release() def resizeGL(self, w, h): |