the code has been contributed to pyglet