aboutsummaryrefslogtreecommitdiff
path: root/vendor/hare-sdl2/sdl2/pixels.ha
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/pixels.ha
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/pixels.ha55
1 files changed, 55 insertions, 0 deletions
diff --git a/vendor/hare-sdl2/sdl2/pixels.ha b/vendor/hare-sdl2/sdl2/pixels.ha
new file mode 100644
index 0000000..7aa8733
--- /dev/null
+++ b/vendor/hare-sdl2/sdl2/pixels.ha
@@ -0,0 +1,55 @@
+// TODO: Flesh me out
+use types::c;
+
+export type SDL_Color = struct {
+ r: u8,
+ g: u8,
+ b: u8,
+ a: u8,
+};
+
+export type SDL_Palette = struct {
+ ncolors: int,
+ colors: *SDL_Color,
+ version: u32,
+ refcount: int,
+};
+
+// Note: Everything in the pixel format structure is read-only.
+export type SDL_PixelFormat = struct {
+ format: u32, // TODO
+ palette: *SDL_Palette,
+ bitsperpixel: u8,
+ bytesperpixel: u8,
+ padding: [2]u8,
+ rmask: u32,
+ gmask: u32,
+ bmask: u32,
+ amask: u32,
+ rloss: u8,
+ gloss: u8,
+ bloss: u8,
+ aloss: u8,
+ rshift: u8,
+ gshift: u8,
+ bshift: u8,
+ ashift: u8,
+ refcount: int,
+ next: nullable *SDL_PixelFormat,
+};
+
+export def SDL_PIXELFORMAT_ARGB8888: u32 = 0x16362004;
+
+@symbol("SDL_GetPixelFormatName") fn _SDL_GetPixelFormatName(format: u32)
+ const *c::char;
+
+// Get the human readable name of a pixel format.
+export fn SDL_GetPixelFormatName(format: u32) str = {
+ return c::tostr(_SDL_GetPixelFormatName(format))!;
+};
+
+// Map an RGB triple to an opaque pixel value for a given pixel format.
+export @symbol("SDL_MapRGB") fn SDL_MapRGB(format: *SDL_PixelFormat, r: u8, g: u8, b: u8) u32;
+
+// Map an RGBA quadruple to a pixel value for a given pixel format.
+export @symbol("SDL_MapRGBA") fn SDL_MapRGBA(format: *SDL_PixelFormat, r: u8, g: u8, b: u8, a: u8) u32;