aboutsummaryrefslogtreecommitdiff
path: root/sdl2
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2021-12-09 16:16:33 +0100
committerDrew DeVault <sir@cmpwn.com>2021-12-09 16:16:33 +0100
commit4b9ce55ebe2fce02841a2d5d283b5f02f9a534eb (patch)
tree05b6a204b4b1a42ee7b78326916489c6db8a0179 /sdl2
parentcmd/demo: add hare mascot (diff)
downloadhare-chip8-4b9ce55ebe2fce02841a2d5d283b5f02f9a534eb.tar.gz
Add timer.h functions
Diffstat (limited to 'sdl2')
-rw-r--r--sdl2/timer.ha32
-rw-r--r--sdl2/video.ha13
2 files changed, 45 insertions, 0 deletions
diff --git a/sdl2/timer.ha b/sdl2/timer.ha
new file mode 100644
index 0000000..da958b6
--- /dev/null
+++ b/sdl2/timer.ha
@@ -0,0 +1,32 @@
+// Get the number of milliseconds since SDL library initialization.
+//
+// This value wraps if the program runs for more than ~49 days.
+//
+// Returns an unsigned 32-bit value representing the number of milliseconds
+// since the SDL library initialized.
+export @symbol("SDL_GetTicks") fn getticks() u32;
+
+// Get the current value of the high resolution counter.
+//
+// This function is typically used for profiling.
+//
+// The counter values are only meaningful relative to each other. Differences
+// between values can be converted to times by using
+// [[getperformancefrequency]].
+//
+// Returns the current counter value.
+export @symbol("SDL_GetPerformanceCounter") fn getperformancecounter() u64;
+
+// Get the count per second of the high resolution counter.
+//
+// Returns a platform-specific count per second.
+export @symbol("SDL_GetPerformanceFrequency") fn getperformancefrequency() u64;
+
+// Wait a specified number of milliseconds before returning.
+//
+// This function waits a specified number of milliseconds before returning. It
+// waits at least the specified time, but possibly longer due to OS
+// scheduling.
+export @symbol("SDL_Delay") fn delay(ms: u32) void;
+
+// TODO: Timers
diff --git a/sdl2/video.ha b/sdl2/video.ha
index e12ca12..e6dfa58 100644
--- a/sdl2/video.ha
+++ b/sdl2/video.ha
@@ -71,3 +71,16 @@ export @symbol("SDL_CreateWindow") fn create_window(title: const *char,
// Destroy a window.
export @symbol("SDL_DestroyWindow") fn destroy_window(window: *window) void;
+
+// Get the size of a window's client area.
+//
+// Null may safely be passed as the 'w' or 'h' parameter if the width or
+// height value is not desired.
+//
+// The window size in screen coordinates may differ from the size in pixels, if
+// the window was created with `ALLOW_HIGHDPI` on a platform with high-dpi
+// support (e.g. iOS or macOS). Use [[gl_getdrawablesize]],
+// [[vulkan_getdrawablesize]], or [[getrendereroutputsize]] to get the real
+// client area size in pixels.
+export @symbol("SDL_GetWindowSize") fn get_window_size(window: *window,
+ w: nullable *int, h: nullable *int) void;