forked from prideout/coregl-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanvas.py
More file actions
34 lines (28 loc) · 914 Bytes
/
canvas.py
File metadata and controls
34 lines (28 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from PyQt5.QtOpenGL import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from OpenGL.GL import *
from time import time
# Set this 'None' to refresh as rapidly as possible
ThrottleFps = 60
class Canvas(QGLWidget):
def __init__(self, parent):
if hasattr(QGLFormat, 'setVersion'):
f = QGLFormat(); f.setVersion(3, 2)
f.setProfile(QGLFormat.CoreProfile)
c = QGLContext(f)
QGLWidget.__init__(self, c, parent)
else:
QGLWidget.__init__(self, parent)
self.timer = QTimer()
self.timer.timeout.connect(self.updateGL)
interval = 1000.0 / ThrottleFps if ThrottleFps else 0
self.timer.start( interval )
def paintGL(self):
self.draw()
def updateGL(self):
self.draw()
self.update()
def draw(self):
pass