None of this is a problem under v1.0. Framerate is rock-solid, no
tearing is visible. Code to use v1.0 API looks like:
---------------------------
import sys
from os.path import abspath, dirname
sys.path.insert(0, abspath('.'))
from pyglet import window, clock, version, __file__
print "Pyglet %s [%s]" % (version, dirname(__file__))
win = window.Window(vsync=True)
clockDisplay = clock.ClockDisplay()
ticks = []
def update(dt):
ticks.append(dt)
def on_draw():
win.clear()
clockDisplay.draw()
clock.set_fps_limit(30)
while not win.has_exit:
dt = clock.tick()
update(dt)
win.dispatch_events()
on_draw()
win.flip()
print "Tick times in ms:", ", ".join("%.0f" % (dt*1000) for dt in
ticks)
---------------
Output looks like:
Pyglet 1.0 [/home/jhartley/projects/sole-scion/src/pyglet]
Tick times in ms: 0, 67, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
33, 33, 33, 33,
33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
33, 33, 33, 33,
33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
33, 33, 33, 33
On Jun 20, 12:36 pm, Tartley <[EMAIL PROTECTED]> wrote:
> Hey there,
>
> Moving the mouse causes the framerate of my Pyglet application to
> increase massively (from the requested 30fps to about 80fps.) When I
> stop moving the mouse, the framerate becomes very slow and jerky
> (alternating between frames of ~2ms and ~250ms). This jerkiness lasts
> for about as long as the duration of the former mouse movement.
> Presumably the event loop is trying to slow down to compensate for the
> very fast frames earlier.
>
> Even when I don't touch the mouse, while the framerate hovers around
> 30fps, every so often (a few times per second) I get a really fast
> frame (~2ms), followed by one or two really slow ones (~90ms.)
>
> Presumably events are short-cutting the sleep that happens between
> each frame. Mouse events come in a prolific stream, causing every
> frame to be shortened. Other events come occasionally, causing the
> sporadic deviations from 30fps.
>
> Also, possibly related, I am still seeing tearing when I add some
> rapidly moving polygons into the draw event, even though printing
> window.vsync reports True. Changing vsync to False does not change the
> framerate issue.
>
> I've reduced my code to what I *believe* is a fairly canonical event
> loop (below)
>
> This is on 1.1beta, Ubuntu 8.04, on a dual core thinkpad T60. I'll try
> it out on v1.0, see how that goes, post results here. In the meantime,
> Any ideas or suggestions much appreciated.
>
> ---------------------------
> from pyglet import app, clock, window
>
> win = window.Window(vsync=True)
> clockDisplay = clock.ClockDisplay()
> ticks = []
>
> def update(dt):
> ticks.append(dt)
>
> @win.event
> def on_draw():
> win.clear()
> clockDisplay.draw()
>
> clock.set_fps_limit(30)
> clock.schedule(update)
> app.run()
> print "Tick times in ms:", ", ".join("%.0f" % (dt*1000) for dt in
> ticks)
> ---------------------------
>
> Using the above code, I get the following output (with CR and comments
> added manually to document what I think is going on:
>
> ----------------------------
> Tick times in ms:
> # always start with twenty or so very fast frames (1ms per frame.)
> # Unexpected but I can live with it.
> 0 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
>
> # then it settles down to what I requested 30fps (==33ms/frame.)
> # But it is very uneven
> # The min during this 'stable' period is 2ms and the max is 82ms
> 19 32 37 31 29 2 70 31 36 32 33 31 17 2 82 36 32 31 37 32 36 31 32 37
> 32 31 36 17 48 31 36 33 32 36 31 5 64 31 36 33 31 36 21 43 36 32 33 31
> 37 31 9 60 31 36 32 33 31 29 43
>
> # At this point I started moving the mouse. This causes a massive
> frame
> # rate increase, presumably because the mouse event is short-cutting
> the
> # sleep between frames.
> 8 12 12 10 14 11 12 11 12 12 12 12 12 12 13 12 10 11 12 12 11 11 13 11
> 13 12 11 12 11 12 11 12 2 10 12 12 12 11 12 13 6 5 12 11 12 12 12 12
> 12 12 11 12 12 11 11 13 10 12 11 12 11 13 12 12 13 13 12 12 13 12 12
> 10 10 11 12 11 11 13 11 12 12 12 11 12 6 7 2 9 11 11 11 13 12 12 11 12
> 13 11 12 11 12 12 12 12 12 11 11 6 5
>
> # At this point I stopped moving the mouse. Now there is a period of
> very
> # jerky frames alternating between very short and very long,
> presumably
> # while the eventloop attempts to compensate for the short frames
> earlier.
> 251 248 2 250 2 250 2 250 2 250 2 250 2 250 2 250 2 250 3 249 2 250 2
> 190
>
> # eventually it settles back down to 30fps but it is extremely uneven
> again.
> # Min=2ms max=94ms
> 36 24 2 75 32 32 36 31 36 8 2 86 36 32 36 33 28 39 32 33 31 36 33 31
> 17 51 36 33 31 32 37 32 31 36 33 32 36 32 31 21 51 33 31 32 36 33 31 5
> 63 33 31 36 32 36 20 48 32 32 3 3 31 36 32 5 2 94 31 40 29
>
> # final frame is always very long. No big deal.
> 150
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---