Refactor
This commit is contained in:
41
tools/editor/map/glwidget.py
Normal file
41
tools/editor/map/glwidget.py
Normal file
@@ -0,0 +1,41 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user