summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-03-13 21:14:53 +0000
committeronelin <oscar@nelin.dk>2025-03-13 21:14:53 +0000
commit40593e796e64a25efb97b158453f053fb77f95b3 (patch)
tree2fd0253018f4c744a96ed2693c0cb91b3586d6ce /src
parent74f81c7007aba4dbe284be4154bd1cc97e7a4548 (diff)
Use OS timer
Diffstat (limited to 'src')
-rw-r--r--src/rendering/src/window.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/rendering/src/window.c b/src/rendering/src/window.c
index 8b964ce..8514bb4 100644
--- a/src/rendering/src/window.c
+++ b/src/rendering/src/window.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <time.h>
/* TODO: REMOVE THIS INCLUSION */
#include <engine/engine.h>
@@ -69,6 +70,16 @@ static inline u64 glfw_gettime_nsec() {
return (f64)glfwGetTime() * 1000000000;
}
+static inline u64 platform_get_time() {
+ struct timespec t;
+ int res = clock_gettime(CLOCK_MONOTONIC, &t);
+ if (res != 0) {
+ // TODO: Check errno
+ WARN("Failed to get system time");
+ }
+ return t.tv_sec * 1000000000 + t.tv_nsec;
+}
+
Window* init_window_glfw(
const char* windowtitle, ivec2 windowsize,
const u32 flags
@@ -134,7 +145,7 @@ Window* init_window_glfw(
ret->context = NULL;
window_poll_events = &glfwPollEvents;
- get_time = &glfw_gettime_nsec;
+ get_time = &platform_get_time;
return ret;
}