Convert ticks to 64-bit, added nanosecond precision to the API

Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
This commit is contained in:
Sam Lantinga
2022-12-02 01:17:17 -08:00
parent 764b899a13
commit 8121bbd083
96 changed files with 938 additions and 1243 deletions

View File

@@ -31,8 +31,9 @@ static int cycle_direction = 1;
static int current_alpha = 255;
static int current_color = 255;
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
static Uint32 next_fps_check, frames;
static const Uint32 fps_check_delay = 5000;
static Uint64 next_fps_check;
static Uint32 frames;
static const int fps_check_delay = 5000;
int done;
@@ -175,7 +176,7 @@ void DrawRects(SDL_Renderer *renderer)
void loop()
{
Uint32 now;
Uint64 now;
int i;
SDL_Event event;
@@ -204,9 +205,9 @@ void loop()
#endif
frames++;
now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, next_fps_check)) {
if (now >= next_fps_check) {
/* Print out some timing information */
const Uint32 then = next_fps_check - fps_check_delay;
const Uint64 then = next_fps_check - fps_check_delay;
const double fps = ((double)frames * 1000) / (now - then);
SDL_Log("%2.2f frames per second\n", fps);
next_fps_check = now + fps_check_delay;