commit 32bd2ed
uint
·
2026-06-22 23:18:56 +0000 UTC
parent 4fecdfe
Use win32 sleeping function in maus_target_fps
1 files changed,
+5,
-1
+5,
-1
1@@ -31,7 +31,7 @@ void maus_die(const char* fmt, ...)
2
3 uint64_t maus_get_time_ns(void)
4 {
5-#if !defined(WIN32)
6+#if !defined(_WIN32)
7 struct timespec ts;
8 clock_gettime(CLOCK_MONOTONIC, &ts);
9 return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
10@@ -71,10 +71,14 @@ void maus_target_fps(Maus* mw, uint32_t fps)
11 /* if early finish, sleep for the remaining time balance */
12 if (elapsed < ns_frame) {
13 uint64_t sleep = ns_frame - elapsed;
14+ #if !defined(_WIN32)
15 struct timespec ts;
16 ts.tv_sec = sleep / 1000000000ULL;
17 ts.tv_nsec = sleep % 1000000000ULL;
18 nanosleep(&ts, NULL);
19+ #else /* unix */
20+ Sleep((DWORD)((sleep + 999999ULL) / 1000000ULL));
21+ #endif /* platform */
22 }
23
24 mw->frame_time_last = maus_get_time_ns();