From cf8227d7d3d625d83804e53b8bec5d8c3ce8516b Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Sun, 26 Jan 2025 12:06:00 +0300 Subject: [PATCH] twn_loop.c: place SDL_Delay() to not waste CPU time --- src/twn_loop.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/twn_loop.c b/src/twn_loop.c index 0310358..3ed5736 100644 --- a/src/twn_loop.c +++ b/src/twn_loop.c @@ -252,6 +252,10 @@ static void main_loop(void) { /* which for now is broken as glBufferData with NULL is used all over right after render */ if (frames != 0) render(); + else + /* don't waste clock cycles on useless work */ + /* TODO: make it adjustable from config */ + SDL_Delay((uint32_t)(ctx.desired_frametime - ctx.frame_accumulator) / 1250000); }