From 42bf617798a9cd096046d7a9fca3b7b4d23a7a6a Mon Sep 17 00:00:00 2001 From: Brian Whitman Date: Sun, 16 Jun 2024 11:18:12 -0400 Subject: [PATCH] . --- tulip/linux/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tulip/linux/main.c b/tulip/linux/main.c index 98e82aa6d..821c07e3d 100644 --- a/tulip/linux/main.c +++ b/tulip/linux/main.c @@ -907,6 +907,12 @@ int main(int argc, char **argv) { while(c>=0) { // unix_display_draw returns -1 if the window was quit c = unix_display_draw(); + if(c>=0) { + // Figure out how long to sleep. ticks has the amount of time already spent for this frame + // so let's fill in the rest with a usleep. + int sleep_ms_for_frame = (int) ((1000.0/TARGET_DESKTOP_FPS) - ticks); + if(sleep_ms_for_frame > 0) usleep(1000*sleep_ms_for_frame); + } } if(c==-2) { // signal to restart display after a timing change