summaryrefslogtreecommitdiff
path: root/src/util/time.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/time.h')
-rw-r--r--src/util/time.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/time.h b/src/util/time.h
new file mode 100644
index 0000000..ae696c5
--- /dev/null
+++ b/src/util/time.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <SDL.h>
+#include <SDL_timer.h>
+
+#include "typedef.h"
+
+const U32 TICK_RESOLUTION = 1000000;
+
+inline U64 u_tick() {
+ return (SDL_GetPerformanceCounter() * TICK_RESOLUTION / SDL_GetPerformanceFrequency());
+}
+
+inline F32 u_time() {
+ return (F32)((F64)u_tick() / TICK_RESOLUTION);
+}
+
+inline F64 u_time64() {
+ return (F64)u_tick() / TICK_RESOLUTION;
+}
+