aboutsummaryrefslogtreecommitdiff
path: root/sdl2/render.ha
diff options
context:
space:
mode:
authorCarlos Une <une@fastmail.fm>2022-10-25 01:26:08 -0300
committerDrew DeVault <sir@cmpwn.com>2022-11-07 12:24:39 +0100
commitc7bde5d2759c693f918d5a621ada339188d9f9a2 (patch)
tree4793ff9e4ae99d722b309d8434e9ff2903ddbc45 /sdl2/render.ha
parentmixer: io::close can error (diff)
downloadhare-chip8-c7bde5d2759c693f918d5a621ada339188d9f9a2.tar.gz
Add SDL_CreateTexture, SDL_UpdateTexture wrappers
Signed-off-by: Carlos Une <une@fastmail.fm>
Diffstat (limited to 'sdl2/render.ha')
-rw-r--r--sdl2/render.ha26
1 files changed, 26 insertions, 0 deletions
diff --git a/sdl2/render.ha b/sdl2/render.ha
index d607712..667c223 100644
--- a/sdl2/render.ha
+++ b/sdl2/render.ha
@@ -195,3 +195,29 @@ export fn SDL_RenderFillRect(
) (void | error) = {
return wrapvoid(_SDL_RenderFillRect(renderer, rect));
};
+
+@symbol("SDL_CreateTexture") fn _SDL_CreateTexture(renderer: *SDL_Renderer,
+ format: u32, access: int, w: int, h: int) *SDL_Texture;
+
+// Create a texture for a rendering context.
+export fn SDL_CreateTexture(renderer: *SDL_Renderer,
+ format: u32, access: int, w: int, h: int) (*SDL_Texture | error) = {
+ return wrapptr(_SDL_CreateTexture(renderer, format, access, w, h))?: *SDL_Texture;
+};
+
+@symbol("SDL_UpdateTexture") fn _SDL_UpdateTexture(texture: *SDL_Texture,
+ rect: const nullable *SDL_Rect, pixels: const nullable *void, pitch: int) int;
+
+// Update the given texture rectangle with new pixel data.
+export fn SDL_UpdateTexture(texture: *SDL_Texture,
+ rect: const nullable *SDL_Rect, pixels: const nullable *void, pitch: int)
+ (int | error) = {
+ return wrapint(_SDL_UpdateTexture(texture, rect, pixels, pitch))?: int;
+};
+
+// An enumeration of texture access patterns.
+export type SDL_TextureAccess = enum int {
+ STATIC,
+ STREAMING,
+ TARGET
+};