Files
dusk/tools/editortool/map/glwidget.py
Dominic Masters b01c0d37b0
Some checks failed
Build Dusk / build-linux (push) Failing after 51s
Build Dusk / build-psp (push) Failing after 55s
Region editor
2025-11-28 08:48:42 -06:00

41 lines
1013 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)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_POLYGON_OFFSET_FILL)
glPolygonOffset(1.0, 1.0)
glDisable(GL_POLYGON_OFFSET_FILL)
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.map.draw()
self.parent.selectBox.draw()