import sys, time, math, os from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * from dmsgl import * startdir = os.getcwd() + os.sep texCamera = OrthoCamera(left=-1.5,right=1.5,bottom=-1.5,top=1.5) tex = Texture2D(startdir + 'circle.tiff') blend = Transparency(blendSource=GL_ONE, blendDest=GL_ONE) circles = [] circles.append([Color([1,0,0,0.4]), 1, 0, 1, 7]) circles.append([Color([0,1,0,0.4]), 1, 1, 1.1, 8]) circles.append([Color([0,0,1,0.4]), 1, 2, 1.2, 9]) circles.append([Color([1,1,0,0.4]), 1, 3, 1.3, 10]) circles.append([Color([1,0,1,0.4]), 1.4, 4, 1, 11]) circles.append([Color([0,1,1,0.4]), 1.5, 5, 1, 12]) circles.append([Color([1,0,0,0.4]), -0.5, 0, 1, 5]) circles.append([Color([0,1,0,0.4]), -0.5, 1, 1.1, 4]) circles.append([Color([0,0,1,0.4]), -0.5, 2, 1.2, 3]) circles.append([Color([1,1,0,0.4]), 0.6, -5, 1.3, 10]) circles.append([Color([1,0,1,0.4]), 0.4, -3, 1, 11]) circles.append([Color([0,1,1,0.4]), 0.7, -4, 1, 12]) circles.append([Color([1,1,0,0.4]), 2.6, -5, -1.3, 1]) circles.append([Color([1,0,1,0.4]), 2.4, -3, -1, -1]) circles.append([Color([0,1,1,0.4]), 2.7, -4, -1, 0]) startTime = time.time() def draw(): t = time.time() - startTime Color.Grey20.clear() texCamera.apply() blend.apply() tex.apply() for c in circles: c[0].apply() glPushMatrix() glTranslatef(math.sin(t*c[1]+c[2]), math.cos(t*c[3]+c[4]), 0) glBegin(GL_QUADS) glTexCoord2i(0,0) glVertex2f(-0.5, -0.5) glTexCoord2i(1,0) glVertex2f(0.5, -0.5) glTexCoord2i(1,1) glVertex2f(0.5, 0.5) glTexCoord2i(0,1) glVertex2f(-0.5, 0.5) glEnd() glPopMatrix() tex.disable() blend.disable() glutSwapBuffers() def keyboard(key, x, y): global cameraVelDist if key == chr(27): sys.exit(0) def update(): glutPostRedisplay() glutInit([]) glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE) glutInitWindowSize(400,400) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutIdleFunc(update) glutMainLoop()