rendered paste bodyfrom OpenGL.GLUT import *
from OpenGL.GL import *
from OpenGL.GLU import *
def draw():
glColor3f(1.0,0.0,0.0)
glRecti(-100,100,-100,100)
glutSwapBuffers()
def init():
glClearColor(0.0, 0.0, 0.0, 1.0)
def resize(x, y):
if y == 0:
y = 1
glViewport(0, 0, x, y)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
aspect = float(x) / y
if x > y:
glOrtho(-100.0, 100.0, 100.0/aspect, -100.0/aspect, 100.0, -100.)
else:
glOrtho(-100.0*aspect, 100.0*aspect, 100.0, -100.0, 100.0, -100.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
def main(window_name):
glutInitDisplayMode(GLUT_DOUBLE)
glutCreateWindow(window_name)
glutDisplayFunc(draw)
glutReshapeFunc(resize)
init()
glutMainLoop()
if __name__ == '__main__':
main(__file__)