pyqt6 не может найти QOpenGLFunctions
NameError: name 'QOpenGLFunctions' is not defined
from PyQt6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from PyQt6.QtCore import QTimer
from PyQt6.QtOpenGLWidgets import QOpenGLWidget
from PyQt6.QtOpenGL import *
from OpenGL.GL import *
from OpenGL.GLU import *
class CubeOpenGLWidget(QOpenGLWidget, QOpenGLFunctions):
def __init__(self, parent=None):
super().__init__(parent)
self.timer = QTimer(self)
self.timer.timeout.connect(self.updateRotation)
self.timer.start(10)
self.rotation = 0
def initializeGL(self):
self.initializeOpenGLFunctions()
glClearColor(0.0, 0.0, 0.0, 1.0)
glEnable(GL_DEPTH_TEST)
def resizeGL(self, w, h):
glViewport(0, 0, w, h)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45, w / h, 0.1, 50.0)
glMatrixMode(GL_MODELVIEW)
def paintGL(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(0.0, 0.0, -5)
glRotatef(self.rotation, 3, 1, 1)
self.drawCube()
def drawCube(self):
glBegin(GL_LINES)
for edge in edges:
for vertex in edge:
glVertex3fv(verticies[vertex])
glEnd()
def updateRotation(self):
self.rotation += 1
self.update()
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
central_widget = QWidget(self)
layout = QVBoxLayout(central_widget)
glWidget = CubeOpenGLWidget(self)
layout.addWidget(glWidget)
self.setCentralWidget(central_widget)
def main():
app = QApplication([])
window = MainWindow()
window.setGeometry(100, 100, 800, 600)
window.show()
app.exec()
if __name__ == '__main__':
verticies = (
(1, -1, -1),
(1, 1, -1),
(-1, 1, -1),
(-1, -1, -1),
(1, -1, 1),
(1, 1, 1),
(-1, -1, 1),
(-1, 1, 1)
)
edges = (
(0, 1),
(0, 3),
(0, 4),
(2, 1),
(2, 3),
(2, 7),
(6, 3),
(6, 4),
(6, 7),
(5, 1),
(5, 4),
(5, 7)
)
main()