=pyglet <<Richard Jones, pyglet developer
|
1
=pyglet <<Richard Jones, pyglet developer |
2
why pyglet? this is a question some of you may be asking
|
3
no binaries -<<(no compilation) a big goal of pyglet was to have no additional installation requirements and
definitely no compilation |
4
multiplatform Windows, OS X, Linux
consistent across platforms a lot of the 1.0 development was spent sorting out platform issues |
5
it's well-designed most of the rest of the 1.0 development was spent refining the design of pyglet
and putting in place the design patterns that would shape further development |
6
many screens, many windows it understands multi-head systems
|
7
*and besides... |
8
=Python is good |
9
=OpenGL is good |
10
<<Modern graphics cards are powerful |
11
=Modern Operating Systems -=are mostly good |
12
=ctypes is good -<<(if a little slow) |
13
Put all these together and you get pyglet |
14
<which *>>rocks |
15
aside... -pygame -pyopengl pygame cons: SDL, single window, no multi-head support
pyopengl: it's just OpenGL - no windowing, events, media, etc. |
16
=Components |
17
display... =OpenGL |
18
windowing... =xlib, Carbon, Win32 provide window & screen management, event sources
|
19
import pyglet window = pyglet.window.Window() pyglet.app.run() the most basic pyglet (1.1) app
|
20
import pyglet window = pyglet.window.Window() @window.event def on_text(text): if text == ' ': print 'You hit space' pyglet.app.run() event handlers are recognised by name
if you want to handle multiple events you create an object with the handlers |
21
imaging... =gdk-pixbuf, Quicktime, GDI+ pyglet can load PNG (slowly), a subset of DDS (S3TC) textures
other libraries used to support other formats |
22
which lets me do *this |
23
![]() |
24
![]() "awww..." |
25
![]() "awww..." |
26
import pyglet
window = pyglet.window.Window()
image = pyglet.image.load('kitten.jpg')
@window.event
def on_draw():
image.blit(0, 0)
pyglet.app.run() |
27
optionally... =PIL lets us decode strange many formats
|
28
aside... =libpng, libjpeg tried to use them initially
prevalent setjmp and longjmp confuse ctypes |
29
audio output... =OpenAL, ALSA, DirectSound OpenAL and ALSA (if we must) on Linux
OpenAL on OS X DirectSound on Windows |
30
which lets me do |
31
this |
32
import pyglet
sound = pyglet.media.load('sound.wav')
sound.play()
pyglet.app.run() |
33
fonts... =fontconfig, freetype2, ATS, Win32 |
34
which lets me do *this -/and this -:and this -*/:<and so on... |
35
ChozCunningham_-_Limberjack.ttf |
36
=Or This -*<<<"Or This" |
37
import pyglet
window = pyglet.window.Window()
text = pyglet.text.Label("Or This",
'Limberjack', 200,
color=(105,200,105,255))
@window.event
def on_draw():
text.draw()
pyglet.app.run() |
38
=Media decoding pyglet can play WAV files with no support
|
39
=Linux media is a mess |
40
gstreamer -unreliable installs -wants to own playback and threads
|
41
libavcodec -no stable ABI used by ffmpeg, mplayer, etc
|
42
libxine / libvlc -not common enough |
43
libmad, libvorbis, ... -not common enough -no video support |
44
PyMedia -not common enough -LGPL pgylet is BSD
|
45
<<<if you don't believe me... <<<http://code.google.com/p/pyglet/wiki/MediaOnLinux |
46
<<we also used Quicktime DirectShow -but they were fiddly |
47
bring on <http://code.google.com/p/avbin interface to libavcodec
reliable ABI |
48
"what?" I hear you say
|
49
"what about *the first rule of pyglet?" |
50
no binary? -simply no alternative |
51
and media... |
52
Video: TheMeaningOfLife.avi
|
53
import pyglet
video = pyglet.media.load('video.avi')
player = media.Player()
player.queue(video)
player.play()
@window.event
def on_draw():
player.texture.blit(0, 0)
pyglet.app.run() |
54
=pyglet 1.0 features -<<Multiple windows -<<Multiple screens (and displays (X11)) -<<OpenGL contexts shared or independent -<<Streaming audio and video -<<TTF and Type 1 Postscript antialiased fonts |
55
=pyglet 1.1 features -<<Resource loading -<<Event loop -<<Graphics buffers -<<Fast sprites -<<Fast text -<<Formatted text layout -<<Animated GIF support |
56
=third parties -<<<(a sampler) -Cocos -rabbyt -ToGEPy a sprite and game engine written to run over pyglet
a nice sprite and animation system, written in pyrex a thinner interface to OpenGL than PyOpenGL, written in C |
57
=credits <<Patrick Hofman for the foot image <<*fonts from <http://openfontlibrary.org/>: <<!Limberjack font by ChozCunningham |
58
pyglet.txt |
59
=pyglet BOF Haneda B 2:45 -*Questions? |