aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py')
-rw-r--r--sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py48
1 files changed, 27 insertions, 21 deletions
diff --git a/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py b/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py
index a1e2a40d7..3e6bc4c9d 100644
--- a/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py
+++ b/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py
@@ -12,18 +12,19 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from helper.usesqguiapplication import UsesQGuiApplication
+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)
+ QSurfaceFormat)
+from PySide6.QtOpenGL import QOpenGLTexture, QOpenGLWindow
try:
from OpenGL import GL
+ from PySide6.QtOpenGL import QOpenGLVersionProfile, QOpenGLVersionFunctionsFactory
except ImportError:
- print("Skipping test due to missing OpenGL module")
+ print("Skipping test due to missing OpenGL module/GLES only build")
sys.exit(0)
@@ -41,42 +42,47 @@ 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):
self.m_functions.glViewport(0, 0, self.width(), self.height())
-class QOpenGLWindowTest(UsesQGuiApplication):
+class QOpenGLWindowTest(UsesQApplication):
# On macOS, glClear(), glViewport() are rejected due to GLbitfield/GLint not being resolved properly
def test(self):
openGlWindow = OpenGLWindow()