# Beginning of a program to draw a simple 2D grid. import sys from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * def draw(): glClear(GL_COLOR_BUFFER_BIT) for i in range(0,20): glBegin(GL_LINES) x = i/10.0 - 1 y = -1 glVertex2f(x,y) x = i/10.0 - 1 y = 1 glVertex2f(x,y) glEnd() glFlush() def reshape(w,h): pass def keyboard(key, x, y): if key == 'q': sys.exit(0) elif key == ' ': print 'Mouse is at', x, y glutInit([]) glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB) glutInitWindowSize(500, 500) glutInitWindowPosition(0,0) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutReshapeFunc(reshape) glutMainLoop()