##// END OF EJS Templates
Event loop integration example
Nicolas Rougier -
Show More
@@ -0,0 +1,46 b''
1 #!/usr/bin/env python
2 """Simple GLUT example to manually test event loop integration.
3
4 This is meant to run tests manually in ipython as:
5
6 In [5]: %gui glut
7
8 In [6]: %run gui-glut.py
9
10 In [7]: gl.glClearColor(1,1,1,1)
11 """
12
13 #!/usr/bin/env python
14 import sys
15 import OpenGL.GL as gl
16 import OpenGL.GLUT as glut
17
18 def display():
19 gl.glClear (gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
20 glut.glutSwapBuffers()
21
22 def resize(width,height):
23 gl.glViewport(0, 0, width, height+4)
24 gl.glMatrixMode(gl.GL_PROJECTION)
25 gl.glLoadIdentity()
26 gl.glOrtho(0, width, 0, height+4, -1, 1)
27 gl.glMatrixMode(gl.GL_MODELVIEW)
28
29
30 if glut.glutGetWindow() > 0:
31 interactive = True
32 glut.glutInit(sys.argv)
33 glut.glutInitDisplayMode(glut.GLUT_DOUBLE |
34 glut.GLUT_RGBA |
35 glut.GLUT_DEPTH)
36 glut.glutShowWindow()
37 else:
38 glut.glutCreateWindow('gui-glut')
39 interactive = False
40
41 glut.glutDisplayFunc(display)
42 glut.glutReshapeFunc(resize)
43 gl.glClearColor(0,0,0,1)
44
45 if not interactive:
46 glut.glutMainLoop()
General Comments 0
You need to be logged in to leave comments. Login now