on_draw continuously triggering when there is no `on_update` nor desktop events

66 views
Skip to first unread message

Matan

unread,
Apr 18, 2023, 9:00:06 AM4/18/23
to pyglet-users
Hi,

Just wondering why does pyglet keep calling `on_draw` even when no updates are made in user code (even when no user `on_update` callback is registered) and no keyboard, mouse events are happening nor any desktop events such as windows moving on top the pyglet window or anything. 

When the desktop is idle of any user interaction or windows moving, `on_draw` is called continuously.

Is that expected behavior?

I was under impression that `on_draw` is called only when there is a reason to redraw, and if we assumed that all updates affecting a draw occur either on the user `on_update` callback or due to desktop events ....

I was just going to implement something akin to a video player where I would control the intervals by always scheduling the next update according to the time of the next "frame" at a variable rate when I bumped into this behavior when stripping away my update callback. 

Made me think about its frequency in general.

This is on Ubuntu.

Thanks for your comment,

ragnar...@gmail.com

unread,
Apr 18, 2023, 12:55:08 PM4/18/23
to pyglet-users
This was changed in 2.0, on request, due to confusion about events being tied to the draw. They wanted constant FPS regardless of what events were taking place without having to schedule an update.

Matan

unread,
Jun 4, 2023, 4:35:04 PM6/4/23
to pyglet-users
I'm not sure what had been confusing and whether the new patterns this implies for library users are cleaner than prior to this change, but it would be nice if this was made merely optional. Or do you think it makes more sense as it is now?

BTW I hope they document api changes of this magnitude in boldface when they are released.

Matan

unread,
Jul 7, 2023, 12:26:56 PM7/7/23
to pyglet-users
BTW, this obviously contradicts the official documenation:

Matan

unread,
Jul 7, 2023, 12:27:58 PM7/7/23
to pyglet-users
Sorry, I mean not really aligned with it. 

Greg Ewing

unread,
Jul 7, 2023, 8:39:31 PM7/7/23
to pyglet...@googlegroups.com
On 8/07/23 4:26 am, Matan wrote:
> I'm not sure what had been confusing and whether the new patterns
> this implies for library users are cleaner than prior to this
> change, but it would be nice if this was made merely optional.

While developing my Albow library I realised that there are two kinds
of games, real-time ones where updates happen at a fixed rate, and
non-real-time ones where things only ever change in response to user
input.

My solution was to have a configuration option. It sounds like something
similar would be in order here.

--
Greg
This email may be confidential and subject to legal privilege, it may not reflect the views of the University of Canterbury, and it is not guaranteed to be virus free. If you are not an intended recipient, please notify the sender immediately and erase all copies of the message and any attachments.
Reply all
Reply to author
Forward
0 new messages