-
Notifications
You must be signed in to change notification settings - Fork 2
/
OpenGL_Window_GLUT.py
48 lines (35 loc) · 941 Bytes
/
OpenGL_Window_GLUT.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'''
Simple GLUT-based init and double-buffered OpenGL rendering
Use keys to rotate the view
'''
from OpenGL.GLUT import *
import sys
from Renderers.Renderer3D import *
global render
def specialkeys(key, x, y):
global render
if key == GLUT_KEY_UP:
render.RotateView(0., 5.)
if key == GLUT_KEY_DOWN:
render.RotateView(0., -5.)
if key == GLUT_KEY_LEFT:
render.RotateView(5., 0.)
if key == GLUT_KEY_RIGHT:
render.RotateView(-5., 0.)
glutPostRedisplay()
def draw():
global render
render.Render()
glutSwapBuffers()
def main():
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
glutInitWindowSize(300, 300)
glutInitWindowPosition(50, 50)
glutInit(sys.argv)
glutCreateWindow(b"OpenGL GLUT Window - Use arrow keys")
glutDisplayFunc(draw)
glutSpecialFunc(specialkeys)
global render
render = SceneRenderer(300, 300)
glutMainLoop()
main()