import sys from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * def draw(): glClear(GL_COLOR_BUFFER_BIT) glFlush() # This cheat is necessary to make the single-buffer problem clear on my iBook glBegin(GL_TRIANGLES) glVertex2f(0.0, 0.0) glVertex2f(0.4, 0.0) glVertex2f(0.8, 0.8) glEnd() glFlush() glutPostRedisplay() def keyboard(key, x, y): if key == chr(27): sys.exit(0) glutInit([]) glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB) glutInitWindowSize(300, 300) glutInitWindowPosition(0,0) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutMainLoop()