Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in
read-only mode
.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
PyOpenGL 3.1.6
When I close the window, I get an "Invalid operation" error in resizeGL() on the line with the glViewport() function. This happens with PyQt6 and PySide6.
import sys
from OpenGL.GL import *
from PyQt6.QtCore import Qt
from PyQt6.QtOpenGL import QOpenGLWindow
from PyQt6.QtWidgets import QApplication
class OpenGLWindow(QOpenGLWindow):
def __init__(self):
super().__init__()
def initializeGL(self):
glClearColor(0.2, 0.2, 0.2, 1)
def resizeGL(self, w, h):
glViewport(0, 0, w, h)
def paintGL(self):
glClear(GL_COLOR_BUFFER_BIT)
if __name__ == "__main__":
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseDesktopOpenGL)
app = QApplication(sys.argv)
w = OpenGLWindow()
w.show()
sys.exit(app.exec())
Debugging details:
Traceback (most recent call last):
File "E:\_Projects\OpenGL\basic-examples\animations\set-swap-interval-opengl21-pyqt6-python\opengl_window.py", line 15, in resizeGL
glViewport(0, 0, w, h)
File "E:\ProgramFiles\Python\Python38\lib\site-packages\OpenGL\error.py", line 230, in glCheckError
raise self._errorClass(
OpenGL.error.GLError: GLError(
err = 1282,
description = b'invalid operation',
baseOperation = glViewport,
cArguments = (0, 0, 160, 160)