@@ -0,0 +1,1526 @@
+#!/usr/bin/env python%0A%0A'''%0A'''%0A%0A__docformat__ = 'restructuredtext'%0A__version__ = '$Id$'%0A%0Aimport pyglet.window%0Afrom pyglet.window.event import *%0Aimport time%0A%0Afrom pyglet.GL.VERSION_1_1 import *%0Afrom pyglet.GLU.VERSION_1_1 import *%0Afrom pyglet import clock%0A%0Afactory = pyglet.window.WindowFactory()%0Afactory.config._attributes%5B'doublebuffer'%5D = 1%0A%0Aclass ExitHandler(object):%0A    running = True%0A    def on_close(self):%0A        self.running = False%0A    def on_keypress(self, symbol, modifiers):%0A        if symbol == pyglet.window.key.K_ESCAPE:%0A            self.running = False%0A        return EVENT_UNHANDLED%0Aexit_handler = ExitHandler()%0A%0A%0Adef setup():%0A    glMatrixMode(GL_PROJECTION)%0A    glLoadIdentity()%0A    gluPerspective(60., 1., 1., 100.)%0A%0A    glMatrixMode(GL_MODELVIEW)%0A    glClearColor(1, 1, 1, 1)%0A    glColor4f(.5, .5, .5, .5)%0A%0Adef draw():%0A    global r%0A    glClear(GL_COLOR_BUFFER_BIT)%0A    glLoadIdentity()%0A%0A    r += 1%0A    if r %3E 360: r = 0%0A    glRotatef(r, 0, 0, 1)%0A    glBegin(GL_QUADS)%0A    glVertex3f(-1., -1., -5.)%0A    glVertex3f(-1., 1., -5.)%0A    glVertex3f(1., 1., -5.)%0A    glVertex3f(1., -1., -5.)%0A    glEnd()%0A%0Aw1 = factory.create(width=200, height=200)%0Aw1.push_handlers(exit_handler)%0Aw1.switch_to()%0Asetup()%0A%0Ac = clock.Clock()%0Aw2 = factory.create(width=400, height=400)%0Aw2.push_handlers(exit_handler)%0Aw2.switch_to()%0Asetup()%0A%0A%0Ar = 0%0Awhile exit_handler.running:%0A    c.set_fps(60)%0A%0A    w1.switch_to()%0A    w1.dispatch_events()%0A    draw()%0A    w1.flip()%0A%0A    w2.switch_to()%0A    w2.dispatch_events()%0A    draw()%0A    w2.flip()%0A

Test two windows drawing GL with different contexts.