diff options
author | Tor Norbye <tnorbye@google.com> | 2014-08-21 00:31:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-08-16 04:55:08 +0000 |
commit | 9cde0e3c015174898df8b8f3672185941fad4786 (patch) | |
tree | 80a55c7b59c38377216daaada4e8bc47b69ceb9a /python/helpers/pydev/tests_mainloop/gui-glut.py | |
parent | 3b37877a2561bf9fbe072253a18688807d523505 (diff) | |
parent | d76e3920c56d37c942092b7dca20fcaded81c0a5 (diff) | |
download | idea-9cde0e3c015174898df8b8f3672185941fad4786.tar.gz |
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge"
Diffstat (limited to 'python/helpers/pydev/tests_mainloop/gui-glut.py')
-rw-r--r-- | python/helpers/pydev/tests_mainloop/gui-glut.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/python/helpers/pydev/tests_mainloop/gui-glut.py b/python/helpers/pydev/tests_mainloop/gui-glut.py new file mode 100644 index 000000000000..f05a4bc0beaf --- /dev/null +++ b/python/helpers/pydev/tests_mainloop/gui-glut.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +"""Simple GLUT example to manually test event loop integration. + +To run this: +1) Enable the PyDev GUI event loop integration for glut +2) do an execfile on this script +3) ensure you have a working GUI simultaneously with an + interactive console +4) run: gl.glClearColor(1,1,1,1) +""" + +#!/usr/bin/env python +import sys +import OpenGL.GL as gl +import OpenGL.GLUT as glut + +def close(): + glut.glutDestroyWindow(glut.glutGetWindow()) + +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 + +glut.glutCreateWindow('gui-glut') +glut.glutDisplayFunc(display) +glut.glutReshapeFunc(resize) +# 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) +gl.glClearColor(0,0,0,1) + +if not interactive: + glut.glutMainLoop() |