aboutsummaryrefslogtreecommitdiff
path: root/sdl2/pixels.ha
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-04-13 16:30:46 +0100
committerDrew DeVault <sir@cmpwn.com>2024-04-19 11:10:28 +0200
commitf2e40ecffec519e1094ed829f8735309ae67997f (patch)
tree8168a12577b1a7f38f0a692aa049b5c3debb3e87 /sdl2/pixels.ha
parentAdd SDL_GetRendererOutputSize. (diff)
downloadhare-chip8-f2e40ecffec519e1094ed829f8735309ae67997f.tar.gz
add a few functions
these are some sdl functions i needed for a project. there is not much structure beyond that.
Diffstat (limited to 'sdl2/pixels.ha')
-rw-r--r--sdl2/pixels.ha15
1 files changed, 15 insertions, 0 deletions
diff --git a/sdl2/pixels.ha b/sdl2/pixels.ha
index 75ccb99..7aa8733 100644
--- a/sdl2/pixels.ha
+++ b/sdl2/pixels.ha
@@ -1,4 +1,5 @@
// TODO: Flesh me out
+use types::c;
export type SDL_Color = struct {
r: u8,
@@ -38,3 +39,17 @@ export type SDL_PixelFormat = struct {
};
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;