##// END OF EJS Templates
Merge pull request #8778 from SylvainCorlay/Meta...
Merge pull request #8778 from SylvainCorlay/Meta Use isinstance to check for types

File last commit:

r16134:7f5cbd62
r21631:3ac9be53 merge
Show More
gui-glut.py
51 lines | 1.3 KiB | text/x-python | PythonLexer
Nicolas Rougier
Event loop integration example
r4807 #!/usr/bin/env python
"""Simple GLUT example to manually test event loop integration.
This is meant to run tests manually in ipython as:
In [5]: %gui glut
In [6]: %run gui-glut.py
In [7]: gl.glClearColor(1,1,1,1)
"""
#!/usr/bin/env python
import sys
import OpenGL.GL as gl
import OpenGL.GLUT as glut
Nicolas Rougier
Removed the timer callback in favor of the idle one and re-use wx waiting time after an event is processed. This make things more reactive. Also, the created window is now made insivisible and is not supposed to be ever show or detroyed. Finally, fixed the bug in window closing for linux platform using the glutSetOption available on Freeglut.
r4831 def close():
glut.glutDestroyWindow(glut.glutGetWindow())
Nicolas Rougier
Event loop integration example
r4807 def display():
gl.glClear (gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
glut.glutSwapBuffers()
def resize(width,height):
gl.glViewport(0, 0, width, height+4)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, width, 0, height+4, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
if glut.glutGetWindow() > 0:
interactive = True
glut.glutInit(sys.argv)
glut.glutInitDisplayMode(glut.GLUT_DOUBLE |
glut.GLUT_RGBA |
glut.GLUT_DEPTH)
else:
interactive = False
Nicolas Rougier
Removed the timer callback in favor of the idle one and re-use wx waiting time after an event is processed. This make things more reactive. Also, the created window is now made insivisible and is not supposed to be ever show or detroyed. Finally, fixed the bug in window closing for linux platform using the glutSetOption available on Freeglut.
r4831 glut.glutCreateWindow('gui-glut')
Nicolas Rougier
Event loop integration example
r4807 glut.glutDisplayFunc(display)
glut.glutReshapeFunc(resize)
Nicolas Rougier
Removed the timer callback in favor of the idle one and re-use wx waiting time after an event is processed. This make things more reactive. Also, the created window is now made insivisible and is not supposed to be ever show or detroyed. Finally, fixed the bug in window closing for linux platform using the glutSetOption available on Freeglut.
r4831 # This is necessary on osx to be able to close the window
# (else the close button is disabled)
if sys.platform == 'darwin' and not bool(glut.HAVE_FREEGLUT):
glut.glutWMCloseFunc(close)
Nicolas Rougier
Event loop integration example
r4807 gl.glClearColor(0,0,0,1)
if not interactive:
glut.glutMainLoop()