On 6/21/08, 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)
set_fps_limit can't really do its job in the pyglet 1.1-style loop. An equivalent and better performing solution is to delete the call to set_fps_limit, and instead schedule your update function at the desired rate: clock.schedule_interval(update, 1/30.0) I imagine this will solve your framerate issue under pyglet 1.1. I'll have a look and see if there's an easy fix for set_fps_limit, otherwise I'll probably mark it deprecated in the future. Alex. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
