Files
dusk/tools/editortool/map/glwidget.py
Dominic Masters ae941a0fdb
All checks were successful
Build Dusk / build-linux (push) Successful in 51s
Build Dusk / build-psp (push) Successful in 56s
Fixed crash
2025-11-16 17:24:54 -06:00

35 lines
804 B
Python

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.grid.draw()
self.parent.selectBox.draw()