Use timers with microsecond precision

SDL only provides millisecond precision. Use system timers to get a
better precision.
This commit is contained in:
Romain Vimont
2021-12-06 23:33:59 +01:00
parent ddb9396743
commit 682a691173
2 changed files with 51 additions and 10 deletions

View File

@@ -10,9 +10,11 @@ typedef int64_t sc_tick;
#define SC_TICK_FREQ 1000000 // microsecond
// To be adapted if SC_TICK_FREQ changes
#define SC_TICK_TO_NS(tick) ((tick) * 1000)
#define SC_TICK_TO_US(tick) (tick)
#define SC_TICK_TO_MS(tick) ((tick) / 1000)
#define SC_TICK_TO_SEC(tick) ((tick) / 1000000)
#define SC_TICK_FROM_NS(ns) ((ns) / 1000)
#define SC_TICK_FROM_US(us) (us)
#define SC_TICK_FROM_MS(ms) ((ms) * 1000)
#define SC_TICK_FROM_SEC(sec) ((sec) * 1000000)