mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-19 19:28:28 +00:00
Improved implementation of SDL_DelayPrecise() (thanks @nightmareci!)
Fixes https://github.com/libsdl-org/SDL/issues/10592
This commit is contained in:
parent
25251a9405
commit
c5904d8710
2 changed files with 65 additions and 14 deletions
|
@ -213,7 +213,7 @@ int main(int argc, char *argv[])
|
|||
Uint64 total_overslept = 0;
|
||||
|
||||
start = SDL_GetTicksNS();
|
||||
SDL_DelayNS(1);
|
||||
SDL_DelayPrecise(1);
|
||||
now = SDL_GetTicksNS();
|
||||
actual_delay = (now - start);
|
||||
SDL_Log("Minimum precise delay: %" SDL_PRIu64 " ns\n", actual_delay);
|
||||
|
@ -221,7 +221,7 @@ int main(int argc, char *argv[])
|
|||
SDL_Log("Timing 100 frames at 60 FPS\n");
|
||||
for (i = 0; i < 100; ++i) {
|
||||
start = SDL_GetTicksNS();
|
||||
SDL_DelayNS(desired_delay);
|
||||
SDL_DelayPrecise(desired_delay);
|
||||
now = SDL_GetTicksNS();
|
||||
actual_delay = (now - start);
|
||||
if (actual_delay > desired_delay) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue