Hello,

I have read a few posts on this group and parts of the pyglet
documentation and I cannot figure out if I am doing this correctly or
not.   I have written a small sample program that animates an RGB XYZ
axis.  Currently my test program behaves poorly on my computer (the
animation is fairly jerky).  I am using schedule_interval to update
the rotation of the axis model while drawing the model in the on_draw
event.  I am updating the rotation by using the dt value when I
calculate the rotation.  I have a Intel Core 2 DUO, Windows XP, and an
ATI Radeon 4870 GPU.  Any feedback would be appreciated.

import pyglet
from pyglet import gl

def main ():
    width = 512
    height = 384
    window = pyglet.window.Window(width, height)
    size = 256
    vertex_list = pyglet.graphics.vertex_list(6,
        ('v3f/static', (0,0,0,size,0,0,0,0,0,0,size,
0,0,0,0,0,0,size)),
        ('c3B/static',
(255,0,0,255,0,0,0,255,0,0,255,0,0,0,255,0,0,255)))
    rotation = [0,0,0]

    def on_resize(width, height):
        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.gluPerspective(60, width/float(height), .1, 8192.)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        return pyglet.event.EVENT_HANDLED

    def on_draw ():
        window.clear()
        gl.glLoadIdentity()
        gl.glTranslatef(0, -128, -512)
        gl.glRotatef(rotation[1],0,1,0)
        vertex_list.draw(gl.GL_LINES)

    def update (dt):
        rotation[1] += 90*dt

    window.push_handlers(on_draw, on_resize)
    pyglet.clock.schedule_interval(update, 1/30.)
    pyglet.app.run()

if __name__ == '__main__':
    main()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to