<s> from time import time <EOL> import sys <EOL> import pygly . gl <EOL> import OpenGL . GL as GL <EOL> import OpenGL . GLUT as GLUT <EOL> from application import BaseApplication <EOL> class Application ( BaseApplication ) : <EOL> keys = { <EOL> GLUT . GLUT_KEY_UP : "<STR_LIT>" , <EOL> GLUT . GLUT_KEY_DOWN : "<STR_LIT>" , <EOL> GLUT . GLUT_KEY_LEFT : "<STR_LIT:left>" , <EOL> GLUT . GLUT_KEY_RIGHT : "<STR_LIT:right>" , <EOL> } <EOL> ESCAPE = '<STR_LIT>' <EOL> def __init__ ( self , scene ) : <EOL> """<STR_LIT>""" <EOL> super ( Application , self ) . __init__ ( scene ) <EOL> if self . scene . core_profile : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> GLUT . glutInit ( sys . argv ) <EOL> GLUT . glutInitDisplayMode ( GLUT . GLUT_DOUBLE | GLUT . GLUT_RGBA | GLUT . GLUT_DEPTH ) <EOL> GLUT . glutInitWindowSize ( <NUM_LIT> , <NUM_LIT> ) <EOL> GLUT . glutCreateWindow ( "<STR_LIT>" + scene . name ) <EOL> pygly . gl . print_gl_info ( ) <EOL> self . scene . initialise ( ) <EOL> self . last_time = time ( ) <EOL> GLUT . glutReshapeFunc ( self . on_window_resized ) <EOL> GLUT . glutIdleFunc ( self . idle ) <EOL> GLUT . glutDisplayFunc ( self . render ) <EOL> GLUT . glutKeyboardFunc ( self . on_key_pressed ) <EOL> GLUT . glutKeyboardUpFunc ( self . on_key_released ) <EOL> GLUT . glutSpecialFunc ( self . on_special_key_pressed ) <EOL> GLUT . glutSpecialUpFunc ( self . on_special_key_released ) <EOL> def on_key_pressed ( self , key , x , y ) : <EOL> if key == self . ESCAPE : <EOL> sys . exit ( ) <EOL> self . scene . on_key_pressed ( key ) <EOL> def on_key_released ( self , key , x , y ) : <EOL> self . scene . on_key_released ( key ) <EOL> def on_special_key_pressed ( self , key , x , y ) : <EOL> if key in self . keys : <EOL> self . scene . on_key_pressed ( self . keys [ key ] ) <EOL> print self . keys [ key ] <EOL> def on_special_key_released ( self , key , x , y ) : <EOL> if key in self . keys : <EOL> self . scene . on_key_released ( self . keys [ key ] ) <EOL> def on_window_closed ( self ) : <EOL> pass <EOL> def run ( self ) : <EOL> GLUT . glutMainLoop ( ) <EOL> def on_window_resized ( self , width , height ) : <EOL> """<STR_LIT>""" <EOL> self . scene . on_window_resized ( width , height ) <EOL> def idle ( self ) : <EOL> current_time = time ( ) <EOL> delta = current_time - self . last_time <EOL> self . last_time = current_time <EOL> self . step ( delta ) <EOL> GLUT . glutPostRedisplay ( ) <EOL> def render ( self ) : <EOL> super ( Application , self ) . render ( ) <EOL> GLUT . glutSwapBuffers ( ) </s>
