All pastes #187812 Raw Edit

Mine

public text v1 · immutable
·published 2006-10-01 13:56 UTC
rendered paste body
from 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__)