RustAudio / baseview

low-level window system interface for audio plugin UIs
Apache License 2.0
267 stars 57 forks source link

Ensure a consistent frame pacing in X11 windows #132

Closed robbert-vdh closed 1 year ago

robbert-vdh commented 1 year ago

The next frame's time stamp needs to be computed based on the last frame's, rather than the current time. This ensures that the frame rate is consistent even when some frames take longer to draw than others. This is especially noticeable in debug builds where drawing frames may take much longer than in release builds. My VIZIA GUIs can now run at almost full speed (60-67 FPS) whereas previously the frame rate was in the low 20s at best.

The poll() also needs to compute the delay using the then current time, as the now() from the start of the function doesn't account for the time already spent handling events and drawing frames.