diff options
| author | Drew DeVault <sir@cmpwn.com> | 2021-12-10 09:42:10 +0100 |
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2021-12-10 09:44:50 +0100 |
| commit | 9607eb0de784fab1a99833f567c0eaca72b67e4a (patch) | |
| tree | 7f79a0914a6db1d963d877bed051f6856c54cfa8 /sdl2/video.ha | |
| parent | Makefile: drop -T+libc (diff) | |
| download | hare-chip8-9607eb0de784fab1a99833f567c0eaca72b67e4a.tar.gz | |
all: rig up Hare-native error handling
Diffstat (limited to '')
| -rw-r--r-- | sdl2/video.ha | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sdl2/video.ha b/sdl2/video.ha index e6dfa58..b1f8b22 100644 --- a/sdl2/video.ha +++ b/sdl2/video.ha @@ -1,4 +1,5 @@ // TODO: Flesh me out +use strings; // The type used to identify a window. (Opaque) export type window = void; @@ -32,6 +33,9 @@ export type window_flags = enum u32 { export def WINDOWPOS_UNDEFINED: int = 0x1FFF0000; export def WINDOWPOS_CENTERED: int = 0x2FFF0000; +@symbol("SDL_CreateWindow") fn _create_window(title: const *char, + x: int, y: int, w: int, h: int, flags: window_flags) nullable *window; + // Create a window with the specified position, dimensions, and flags. // // 'title' is the title of the window, in UTF-8 encoding. See [[strings::to_c]] @@ -66,8 +70,18 @@ export def WINDOWPOS_CENTERED: int = 0x2FFF0000; // removed in a future version of SDL. // // See also: [[destroy_window]] [[gl_loadlibrary]], [[vulkan_loadlibrary]]. -export @symbol("SDL_CreateWindow") fn create_window(title: const *char, - x: int, y: int, w: int, h: int, flags: window_flags) nullable *window; +export fn create_window( + title: str, + x: int, + y: int, + w: int, + h: int, + flags: window_flags, +) (*window | error) = { + let title = strings::to_c(title); + defer free(title); + return wrapptr(_create_window(title, x, y, w, h, flags))?: *window; +}; // Destroy a window. export @symbol("SDL_DestroyWindow") fn destroy_window(window: *window) void; |
