From 031605783e630d46b7294d6ac8bfbf5e4884bb82 Mon Sep 17 00:00:00 2001 From: Leo Prikler Date: Mon, 14 Jun 2021 18:35:33 +0200 Subject: Add support for texture blend modes. * sdl2/bindings.scm (sdl-set-texture-blend-mode): New variable. * sdl2/render.scm (set-texture-blend-mode!): New variable. --- doc/api.texi | 5 +++++ sdl2/bindings.scm | 3 +++ sdl2/render.scm | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/doc/api.texi b/doc/api.texi index 288d0a6..8a352a4 100644 --- a/doc/api.texi +++ b/doc/api.texi @@ -1254,6 +1254,11 @@ Set the color mod of @var{texture}. Set the alpha mod of @var{texture}. @end deffn +@deffn {Procedure} set-texture-blend-mode! texture blend-mode +Set the blend of @var{texture} to @var{blend-mode}. @xref{Blend +Modes} for more information. +@end deffn + @node Blend Modes @section Blend Modes diff --git a/sdl2/bindings.scm b/sdl2/bindings.scm index 8d85c63..7f12b45 100644 --- a/sdl2/bindings.scm +++ b/sdl2/bindings.scm @@ -321,6 +321,9 @@ RETURN-TYPE and accept arguments of ARG-TYPES." (define-foreign sdl-get-texture-alpha-mod int "SDL_GetTextureAlphaMod" '(* *)) +(define-foreign sdl-set-texture-blend-mode + int "SDL_SetTextureBlendMode" (list '* int)) + (define-foreign sdl-set-render-draw-blend-mode int "SDL_SetRenderDrawBlendMode" (list '* int)) diff --git a/sdl2/render.scm b/sdl2/render.scm index e12fad1..5c3b9b0 100644 --- a/sdl2/render.scm +++ b/sdl2/render.scm @@ -403,6 +403,12 @@ TEXTURE." (bytevector-uint-ref bv (* 2 (sizeof int)) (native-endianness) (sizeof int)) (bytevector-uint-ref bv (* 3 (sizeof int)) (native-endianness) (sizeof int))))) +(define (set-texture-blend-mode! texture blend-mode) + (unless (zero? (ffi:sdl-set-texture-blend-mode + (unwrap-texture texture) + ((@@ (sdl2 blend-mode) blend-mode-bitmask) blend-mode))) + (sdl-error "set-texure-blend-mode!" "Failed to set texture blend mode"))) + (define (set-texture-color-mod! texture r g b) "Get color mod of TEXTURE as a list of the integers." (unless (zero? (ffi:sdl-set-texture-color-mod (unwrap-texture texture) r g b)) -- cgit v1.2.3