import sys, math, time, string from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * delay = 0 x = 0 y = 0 quadric = 0 def draw(): glClear(GL_COLOR_BUFFER_BIT) global x,y, quadric glLoadIdentity() glTranslatef(x, y, 0) glColor3f(1, 1, 0) gluDisk(quadric, 0, 10, 6, 6) glutSwapBuffers() def reshape(width, height): glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluOrtho2D(0, width, -height, 0) glMatrixMode(GL_MODELVIEW) def keyboard(key, x, y): if key == chr(27): sys.exit(0) def callDraw(i): global x,y x = i % 10000 y = -i / 10000 draw() def mousemotion(mx,my): global delay glutTimerFunc(delay, callDraw, mx + my*10000) glutInit(sys.argv) if len(sys.argv) > 1: delay = string.atof(sys.argv[1]) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(400, 400) glutInitWindowPosition(0,0) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutPassiveMotionFunc(mousemotion) glutReshapeFunc(reshape) quadric = gluNewQuadric() reshape(400,400) glutMainLoop()