From 89dbe1ad56becac574114ecec258dfd464b82633 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 11 Dec 2021 12:50:12 +0100 Subject: Add SetTextureAlphaMod wrapper --- sdl2/render.ha | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sdl2/render.ha') diff --git a/sdl2/render.ha b/sdl2/render.ha index 649e786..0bba541 100644 --- a/sdl2/render.ha +++ b/sdl2/render.ha @@ -123,6 +123,22 @@ export fn set_texture_color_mod( return wrapvoid(_set_texture_color_mod(texture, r, g, b)); }; +@symbol("SDL_SetTextureAlphaMod") fn _set_texture_alpha_mod(texture: *texture, a: u8) int; + +// Set an additional alpha value multiplied into render copy operations. +// +// When this texture is rendered, during the copy operation the source alpha +// value is modulated by this alpha value according to the following formula: +// +// `srcA = srcA * (alpha / 255)` +// +// Alpha modulation is not always supported by the renderer; it will return an +// error if alpha modulation is not supported. +export fn set_texture_alpha_mod(texture: *texture, a: u8) (void | error) = { + // TODO: Double check errors + return wrapvoid(_set_texture_alpha_mod(texture, a)); +}; + @symbol("SDL_RenderCopy") fn _render_copy(renderer: *renderer, texture: *texture, srcrect: nullable *rect, dstrect: nullable *rect) int; -- cgit v1.2.3