aboutsummaryrefslogtreecommitdiff
path: root/vendor/hare-sdl2/sdl2/image
diff options
context:
space:
mode:
authorPolesznyák Márk <contact@pml68.dev>2026-04-06 23:44:45 +0200
committerPolesznyák Márk <contact@pml68.dev>2026-04-06 23:44:45 +0200
commit6637fdded6f3c5fba7e7a378ca7e30d0db11f27d (patch)
tree40f8868ae2140680645b1f90f4a1fc2a378920b3 /vendor/hare-sdl2/sdl2/image
parentdocs: add README (diff)
parentAdd ! after c::fromstr calls to handle nomem (diff)
downloadhare-chip8-6637fdded6f3c5fba7e7a378ca7e30d0db11f27d.tar.gz
Add 'vendor/hare-sdl2/' from commit 'fb6008be0b79a2a24b1ac960316a83f7873b4f39'
git-subtree-dir: vendor/hare-sdl2 git-subtree-mainline: ed088aa81ac23fa48d5ae48ee739c97e0fcb4490 git-subtree-split: fb6008be0b79a2a24b1ac960316a83f7873b4f39
Diffstat (limited to '')
-rw-r--r--vendor/hare-sdl2/sdl2/image/image.ha46
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/hare-sdl2/sdl2/image/image.ha b/vendor/hare-sdl2/sdl2/image/image.ha
new file mode 100644
index 0000000..b4af99e
--- /dev/null
+++ b/vendor/hare-sdl2/sdl2/image/image.ha
@@ -0,0 +1,46 @@
+// TODO: Flesh me out
+// TODO: SDL_RWops
+use sdl2;
+use types::c;
+
+// Flags for [[IMG_Init]].
+export type IMG_InitFlags = enum int {
+ NONE = 0,
+ JPG = 0x00000001,
+ PNG = 0x00000002,
+ TIF = 0x00000004,
+ WEBP = 0x00000008,
+};
+
+@symbol("IMG_Init") fn _IMG_Init(flags: IMG_InitFlags) int;
+
+// Loads dynamic libraries and prepares them for use. Flags should be one or
+// more flags from [[IMG_InitFlags]] OR'd together.
+export fn IMG_Init(flags: IMG_InitFlags) (void | sdl2::error) = {
+ return sdl2::wrapvoid(_IMG_Init(flags));
+};
+
+// Unloads libraries loaded with [[IMG_Init]]
+export @symbol("IMG_Quit") fn IMG_Quit() void;
+
+@symbol("IMG_Load") fn _IMG_Load(file: const *c::char) nullable *sdl2::SDL_Surface;
+
+// Load an image from a file path.
+export fn IMG_Load(file: str) (*sdl2::SDL_Surface | sdl2::error) = {
+ const file = c::fromstr(file)!;
+ defer free(file);
+ return sdl2::wrapptr(_IMG_Load(file))?: *sdl2::SDL_Surface;
+};
+
+@symbol("IMG_LoadTexture") fn _IMG_LoadTexture(SDL_Renderer: *sdl2::SDL_Renderer,
+ file: const *c::char) nullable *sdl2::SDL_Texture;
+
+// Load an image directly into a render texture.
+export fn IMG_LoadTexture(
+ SDL_Renderer: *sdl2::SDL_Renderer,
+ file: str,
+) (*sdl2::SDL_Texture | sdl2::error) = {
+ const file = c::fromstr(file)!;
+ defer free(file);
+ return sdl2::wrapptr(_IMG_LoadTexture(SDL_Renderer, file))?: *sdl2::SDL_Texture;
+};