Thanks for the idea Laurens!

Unfortunately, if you take a look at pyglet.app.EventLoop.idle, you'll
see that on_draw gets dispatched for all windows each time the idle
loop runs. And with a bit more digging, you'll find that the idle loop
runs after every "wakeup" -- either from a GUI event, or after the
minimum scheduled interval.

Thus, while "UpdateMyGUI" only gets called at 10 Hz, every window is
repainted at 30 Hz -- in this case, a 3x waste, since the contents of
the window only change at the slower rate...

The simple solution is to subclass the idle loop to not always call
on_draw, but then the window class needs to take care of doing that
itself. Not a problem, but it makes it harder to use 3rd-party pyglet
window classes. Better, perhaps, would be to have the custom idle loop
decide when to call on_draw based on whether a GUI event happened or
not.

Zach


On Aug 27, 12:15 pm, Laurens <[EMAIL PROTECTED]> wrote:
> Hi!
>
> To answer your original question: don't know ;)
>
> > Basically, I need to run the event loop at like 30Hz to deal with some
> > non-GUI IO issues, but I don't want to force the windows to all re-
> > paint at that rate -- the windows need to re-paint at a much lower
> > minimum framerate, or in response to GUI events. If the idle loop was
> > able to determine the reason for its awakening, this sort of thing
> > would be a bit easier... (Right now, I just have the idle loop never
> > call on_draw on any windows, and instead make the window event
> > handlers call on_draw if that event causes the window to need a
> > repaint.)
>
> Maybe I misunderstand the question, but can't you just schedule your 30 hz 
> task
> to run:
>
> pyglet.clock.schedule_interval(MyNonGuiIOIssues, 1/30)
>
> and optionally also run your drawing thing on a lower rate:
>
> pyglet.clock.schedule_interval(UpdateMyGUI, 0.1)
>
> and also have an onDraw function (which I think is called automagically
> whenever it needs to redraw your window):
>
> @window.event
> def on_draw():
>     window.clear()
>     label.draw()
>
> Wouldn't that address most of the issues? That also nicely seems to seperate 
> the
> tasks into seperate functions. But maybe this solution is not quite what you
> want, since it's not an answer to your question :)
>
> Cheers,
>
> Laurens
--~--~---------~--~----~------------~-------~--~----~
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