diff options
| author | Carlos Une <une@fastmail.fm> | 2022-10-25 01:26:08 -0300 |
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2022-11-07 12:24:39 +0100 |
| commit | c7bde5d2759c693f918d5a621ada339188d9f9a2 (patch) | |
| tree | 4793ff9e4ae99d722b309d8434e9ff2903ddbc45 /sdl2 | |
| parent | mixer: io::close can error (diff) | |
| download | hare-chip8-c7bde5d2759c693f918d5a621ada339188d9f9a2.tar.gz | |
Add SDL_CreateTexture, SDL_UpdateTexture wrappers
Signed-off-by: Carlos Une <une@fastmail.fm>
Diffstat (limited to 'sdl2')
| -rw-r--r-- | sdl2/render.ha | 26 |
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 +}; |
