from PyQt5.QtCore import QTimer from PyQt5.QtWidgets import QOpenGLWidget from OpenGL.GL import * from OpenGL.GLU import * class GLWidget(QOpenGLWidget): def __init__(self, parent): super().__init__(parent) self.parent = parent self.timer = QTimer(self) self.timer.timeout.connect(self.update) self.timer.start(16) # ~60 FPS def initializeGL(self): glClearColor(0.392, 0.584, 0.929, 1.0) glEnable(GL_DEPTH_TEST) def resizeGL(self, w, h): pass def paintGL(self): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() w = self.width() h = self.height() if h <= 0: h = 1 if w <= 0: w = 1 glViewport(0, 0, w, h) self.parent.camera.setup(w, h) self.parent.map.draw() self.parent.grid.draw() self.parent.selectBox.draw()