<s> '''<STR_LIT>''' <EOL> __docformat__ = '<STR_LIT>' <EOL> __version__ = '<STR_LIT>' <EOL> from ctypes import * <EOL> from pyglet . gl import * <EOL> from pyglet . window import Window <EOL> from pyglet import clock <EOL> from layout import * <EOL> from layout . frame import * <EOL> data = '''<STR_LIT>''' <EOL> class CubeDrawable ( ReplacedElementDrawable ) : <EOL> intrinsic_width = <NUM_LIT:32> <EOL> intrinsic_height = <NUM_LIT:32> <EOL> intrinsic_ratio = <NUM_LIT:1.> <EOL> angle = <NUM_LIT:0> <EOL> def __init__ ( self ) : <EOL> from model . geometric import cube_list <EOL> self . cube = cube_list ( ) <EOL> def draw ( self , frame , render_device , left , top , right , bottom ) : <EOL> glPushAttrib ( GL_CURRENT_BIT | GL_LIGHTING_BIT | GL_ENABLE_BIT ) <EOL> glEnable ( GL_LIGHTING ) <EOL> glEnable ( GL_LIGHT0 ) <EOL> glEnable ( GL_COLOR_MATERIAL ) <EOL> glEnable ( GL_DEPTH_TEST ) <EOL> glColor3f ( <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) <EOL> glMatrixMode ( GL_PROJECTION ) <EOL> glPushMatrix ( ) <EOL> glLoadIdentity ( ) <EOL> width = right - left <EOL> height = top - bottom <EOL> centerx = left + width / <NUM_LIT:2> <EOL> centery = bottom + height / <NUM_LIT:2> + window . height <EOL> glTranslatef ( - <NUM_LIT:1> , - <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> glTranslatef ( centerx * <NUM_LIT:2> / window . width , <EOL> centery * <NUM_LIT:2> / window . height , <NUM_LIT:0> ) <EOL> glScalef ( width / window . width , height / window . height , <NUM_LIT:1> ) <EOL> gluPerspective ( <NUM_LIT> , width / float ( height ) , <NUM_LIT:1> , <NUM_LIT:100> ) <EOL> glMatrixMode ( GL_MODELVIEW ) <EOL> glPushMatrix ( ) <EOL> glLoadIdentity ( ) <EOL> vec4 = ( c_float * <NUM_LIT:4> ) <EOL> glLightfv ( GL_LIGHT0 , GL_POSITION , vec4 ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> ) ) <EOL> glLightfv ( GL_LIGHT0 , GL_DIFFUSE , vec4 ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> ) ) <EOL> glTranslatef ( <NUM_LIT:0> , <NUM_LIT:0> , - <NUM_LIT:3> ) <EOL> glRotatef ( <NUM_LIT:30> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> glRotatef ( self . angle , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> self . cube . draw ( ) <EOL> glPopMatrix ( ) <EOL> glMatrixMode ( GL_PROJECTION ) <EOL> glPopMatrix ( ) <EOL> glMatrixMode ( GL_MODELVIEW ) <EOL> glPopAttrib ( ) <EOL> class CubeReplacedElementFactory ( ReplacedElementFactory ) : <EOL> accept_names = [ '<STR_LIT>' ] <EOL> def create_drawable ( self , element ) : <EOL> return CubeDrawable ( ) <EOL> window = Window ( visible = False , resizable = True ) <EOL> layout = Layout ( ) <EOL> layout . add_replaced_element_factory ( CubeReplacedElementFactory ( ) ) <EOL> layout . set_xhtml ( data ) <EOL> window . push_handlers ( layout ) <EOL> @ select ( '<STR_LIT>' ) <EOL> def on_mouse_press ( element , x , y , button , modifiers ) : <EOL> global rate <EOL> rate = - rate <EOL> layout . push_handlers ( on_mouse_press ) <EOL> glClearColor ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> window . set_visible ( ) <EOL> rate = <NUM_LIT:50> <EOL> while not window . has_exit : <EOL> dt = clock . tick ( ) <EOL> CubeDrawable . angle += dt * rate <EOL> print '<STR_LIT>' % clock . get_fps ( ) , <EOL> window . dispatch_events ( ) <EOL> glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) <EOL> glLoadIdentity ( ) <EOL> layout . draw ( ) <EOL> window . flip ( ) </s>
