<s> import ctypes <EOL> import pyglet <EOL> from pyglet . window . xlib import xlib <EOL> from pyglet . gl import * <EOL> from pyglet . gl . glx import * <EOL> def reshape ( width , height ) : <EOL> h = height / float ( width ) <EOL> glViewport ( <NUM_LIT:0> , <NUM_LIT:0> , width , height ) <EOL> glMatrixMode ( GL_PROJECTION ) <EOL> glLoadIdentity ( ) <EOL> glFrustum ( - <NUM_LIT:1.0> , <NUM_LIT:1.0> , - h , h , <NUM_LIT> , <NUM_LIT> ) <EOL> glMatrixMode ( GL_MODELVIEW ) <EOL> glLoadIdentity ( ) <EOL> glTranslatef ( <NUM_LIT:0.0> , <NUM_LIT:0.0> , - <NUM_LIT> ) <EOL> def draw ( ) : <EOL> glClearColor ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) <EOL> def init ( ) : <EOL> pass <EOL> def make_window ( dpy , name , x , y , width , height ) : <EOL> attrib = ( ctypes . c_int * <NUM_LIT:11> ) ( <EOL> GLX_RGBA , <EOL> GLX_RED_SIZE , <NUM_LIT:1> , <EOL> GLX_GREEN_SIZE , <NUM_LIT:1> , <EOL> GLX_BLUE_SIZE , <NUM_LIT:1> , <EOL> GLX_DOUBLEBUFFER , <EOL> GLX_DEPTH_SIZE , <NUM_LIT:1> , <EOL> <NUM_LIT:0> ) <EOL> scrnum = xlib . XDefaultScreen ( dpy ) <EOL> root = xlib . XRootWindow ( dpy , scrnum ) <EOL> visinfo = glXChooseVisual ( dpy , scrnum , attrib ) <EOL> attr = xlib . XSetWindowAttributes ( ) <EOL> attr . background_pixel = <NUM_LIT:0> <EOL> attr . border_pixel = <NUM_LIT:0> <EOL> attr . colormap = xlib . XCreateColormap ( dpy , root , visinfo . contents . visual , <EOL> xlib . AllocNone ) <EOL> attr . event_mask = ( xlib . StructureNotifyMask | <EOL> xlib . ExposureMask | <EOL> xlib . KeyPressMask ) <EOL> mask = ( xlib . CWBackPixel | <EOL> xlib . CWBorderPixel | <EOL> xlib . CWColormap | <EOL> xlib . CWEventMask ) <EOL> win = xlib . XCreateWindow ( dpy , root , <NUM_LIT:0> , <NUM_LIT:0> , width , height , <NUM_LIT:0> , <EOL> visinfo . contents . depth , xlib . InputOutput , <EOL> visinfo . contents . visual , mask , attr ) <EOL> sizehints = xlib . XSizeHints ( ) <EOL> sizehints . x = x <EOL> sizehints . y = y <EOL> sizehints . width = width <EOL> sizehints . height = height <EOL> sizehints . flags = xlib . USSize | xlib . USPosition <EOL> xlib . XSetNormalHints ( dpy , win , sizehints ) <EOL> xlib . XSetStandardProperties ( dpy , win , name , name , <NUM_LIT:0> , None , <NUM_LIT:0> , sizehints ) <EOL> ctx = glXCreateContext ( dpy , visinfo , None , True ) <EOL> xlib . XFree ( visinfo ) <EOL> return win , ctx <EOL> def event_loop ( dpy , win ) : <EOL> while True : <EOL> while xlib . XPending ( dpy ) > <NUM_LIT:0> : <EOL> event = xlib . XEvent ( ) <EOL> xlib . XNextEvent ( dpy , event ) <EOL> if event . type == xlib . Expose : <EOL> pass <EOL> elif event . type == xlib . ConfigureNotify : <EOL> reshape ( event . xconfigure . width , event . xconfigure . height ) <EOL> elif event . type == xlib . KeyPress : <EOL> pass <EOL> draw ( ) <EOL> glXSwapBuffers ( dpy , win ) <EOL> def main ( ) : <EOL> dpy = xlib . XOpenDisplay ( None ) <EOL> win , ctx = make_window ( dpy , '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ) <EOL> xlib . XMapWindow ( dpy , win ) <EOL> glXMakeCurrent ( dpy , win , ctx ) <EOL> reshape ( <NUM_LIT> , <NUM_LIT> ) <EOL> init ( ) <EOL> event_loop ( dpy , win ) <EOL> glXDestroyContext ( dpy , ctx ) <EOL> xlib . XDestroyWindow ( dpy , win ) <EOL> xlib . XCloseDisplay ( dpy ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
