import sys, math, time, string from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * x = 0 y = 0 def draw(): glClear(GL_COLOR_BUFFER_BIT) global x,y glLoadIdentity() glTranslatef(x, y, 0) glColor3f(1, 1, 0) glutWireTeapot(10) glutSwapBuffers() def reshape(width, height): glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluOrtho2D(0, width, 0, height) glMatrixMode(GL_MODELVIEW) def keyboard(key, x, y): if key == chr(27): sys.exit(0) def mousemotion(mx,my): global x,y x = mx y = glutGet(GLUT_WINDOW_HEIGHT) - my glutPostRedisplay() glutInit(sys.argv) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(400, 400) glutInitWindowPosition(0,0) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutMotionFunc(mousemotion) glutReshapeFunc(reshape) reshape(400,400) glutMainLoop()