import sys, math, time, string from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * letters = [] def draw(): glClear(GL_COLOR_BUFFER_BIT) for a in letters: glRasterPos2fv(a[0]) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, ord(a[1])) 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) else: a = [ [x,glutGet(GLUT_WINDOW_HEIGHT)-y], key ] letters.append(a) glutPostRedisplay() glutInit(sys.argv) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(400, 400) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardUpFunc(keyboard) glutReshapeFunc(reshape) reshape(400,400) glutMainLoop()