Skip to content

Sync events with draws #355

@almarklein

Description

@almarklein

@Korijn mentioned in a comment in a pygfx, that game engines usually run a tight loops with the following steps:

  1. Query input device state (joysticks, buttons, mice, etc)
  2. Update world state
  3. Render frame

That got me thinking. Right now, when a mouse event happens, this causes certain state to be changed. If two (or more) such events happen in between two draws, the state is updated twice, but we only see the final state.

We already do some event throttling to reduce this, but we could also aggregate the events and only dispatch them right before doing the draw, which could potentially result in more performance because it avoids calculating stuff that is never shown anyway.

One problem with this is that right now, if nothing changes, there are also no new draws, which is nice to avoid depleting your battery, and safes network traffic when using the notebook. We'd have to dispatch the events on a regular interval. I'm not sure what happens if we ask the GUI to schedule a draw and then not draw it.

Any other caveats?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions