Skip to content

Commit

Permalink
[opengl] add QGL*<->QOpenGL* aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
renefritze committed Dec 27, 2021
1 parent 500de5d commit deceed0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
19 changes: 19 additions & 0 deletions qtpy/QtOpenGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,22 @@
else:
raise PythonQtError('No Qt bindings could be found')

if PYSIDE2:
QOpenGLBuffer = QGLBuffer
QOpenGLContext = QGLContext
QOpenGLColormap = QGLColormap
QOpenGLFormat = QGLFormat
QOpenGLFramebufferObject = QGLFramebufferObject
QOpenGLFramebufferObjectFormat = QGLFramebufferObjectFormat
QOpenGLShader = QGLShader
QOpenGLShaderProgram = QGLShaderProgram

if PYQT5 or PYQT6:
QGLBuffer = QOpenGLBuffer
QGLFramebufferObject = QOpenGLFramebufferObject
QGLFramebufferObjectFormat = QOpenGLFramebufferObjectFormat
QGLShader = QOpenGLShader
QGLShaderProgram = QOpenGLShaderProgram

if PYQT6:
QGLContext = QOpenGLContext
20 changes: 13 additions & 7 deletions qtpy/tests/test_qtopengl.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import pytest

import qtpy
from qtpy import PYSIDE2, PYSIDE6, PYQT5, PYQT6


def test_qtopengl():
"""Test the qtpy.QtOpenGL namespace"""
from qtpy import QtOpenGL
print(qtpy.API)

# This list is take from https://doc.qt.io/qtforpython-5/PySide2/QtOpenGL/index.html
# This list is taken from https://doc.qt.io/qtforpython-5/PySide2/QtOpenGL/index.html
# and may not be exhaustive
assert QtOpenGL.QGL is not None
assert QtOpenGL.QGLBuffer is not None
assert QtOpenGL.QGLColormap is not None
if PYSIDE2 or PYQT5:
assert QtOpenGL.QGL is not None
assert QtOpenGL.QGLBuffer is not None
assert QtOpenGL.QGLFormat is not None
assert QtOpenGL.QGLWidget is not None
assert QtOpenGL.QGLColormap is not None
assert QtOpenGL.QGLPixelBuffer is not None

assert QtOpenGL.QGLContext is not None
assert QtOpenGL.QGLFormat is not None
assert QtOpenGL.QGLFramebufferObject is not None
assert QtOpenGL.QGLFramebufferObjectFormat is not None
assert QtOpenGL.QGLPixelBuffer is not None
assert QtOpenGL.QGLShader is not None
assert QtOpenGL.QGLShaderProgram is not None
assert QtOpenGL.QGLWidget is not None


0 comments on commit deceed0

Please sign in to comment.