-
Notifications
You must be signed in to change notification settings - Fork 1
/
glut_example3d.py
45 lines (37 loc) · 982 Bytes
/
glut_example3d.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
#Based on https://github.com/Habitats/uni/blob/master/img_processing/project/graphics_modern2.py
from OpenGL.GLUT import *
from OpenGL.GLUT.freeglut import *
import common3d
import OpenGL.GL as gl
aspect = 1.
params = None
width, height = None, None
def draw():
common3d.draw(params, aspect)
glutSwapBuffers()
def main():
glutInitDisplayMode(GLUT_RGBA)
glutInitWindowSize(640, 480)
window = glutCreateWindow("Hello world!")
glutReshapeFunc(reshape)
glutDisplayFunc(draw)
glutKeyboardFunc(keyPressed) # Checks for key strokes
global params
params = common3d.init()
glutMainLoop()
def reshape(widthIn, heightIn):
global width, height
width = widthIn
height = heightIn
global aspect
aspect = (width / float(height))
gl.glViewport(0, 0, width, height)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glDisable(gl.GL_CULL_FACE)
gl.glClearColor(0.8, 0.8, 0.8, 1.0)
glutPostRedisplay()
def keyPressed(*args):
sys.exit()
if __name__=="__main__":
glutInit(sys.argv)
main()