From c7bde5d2759c693f918d5a621ada339188d9f9a2 Mon Sep 17 00:00:00 2001 From: Carlos Une Date: Tue, 25 Oct 2022 01:26:08 -0300 Subject: Add SDL_CreateTexture, SDL_UpdateTexture wrappers Signed-off-by: Carlos Une --- sdl2/render.ha | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 +}; -- cgit v1.2.3