Mercurial > repos > blastem
comparison nuklear_ui/blastem_nuklear.c @ 1482:2d203bf73dbd nuklear_ui
Avoid burning a huge amount of CPU in the menu when emulation is not running and vsync is disabled
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 25 Nov 2017 14:42:38 -0800 |
parents | 77a401044935 |
children | 001120e91fed |
comparison
equal
deleted
inserted
replaced
1481:77a401044935 | 1482:2d203bf73dbd |
---|---|
204 nk_input_begin(context); | 204 nk_input_begin(context); |
205 } | 205 } |
206 | 206 |
207 void idle_loop(void) | 207 void idle_loop(void) |
208 { | 208 { |
209 const uint32_t MIN_UI_DELAY = 15; | |
210 static uint32_t last; | |
209 while (current_view != view_play) | 211 while (current_view != view_play) |
210 { | 212 { |
213 uint32_t current = render_elapsed_ms(); | |
214 if ((current - last) < MIN_UI_DELAY) { | |
215 render_sleep_ms(MIN_UI_DELAY - (current - last) - 1); | |
216 } | |
217 last = current; | |
211 render_update_display(); | 218 render_update_display(); |
212 } | 219 } |
213 } | 220 } |
214 static void handle_event(SDL_Event *event) | 221 static void handle_event(SDL_Event *event) |
215 { | 222 { |