diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-07-06 20:25:30 +0200 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2022-07-06 15:51:36 -0400 |
commit | 697a403617b97b4ce333132dae89cb009f6b6e3b (patch) | |
tree | 44708086f19b7ebf8e07e328c0b5348a80b277d9 /sdl2/render.scm | |
parent | 3f5fc49d9885ea88a4271d2d074e3e6192bce1ef (diff) |
Add SDL_UpdateTexture binding.
Diffstat (limited to 'sdl2/render.scm')
-rw-r--r-- | sdl2/render.scm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sdl2/render.scm b/sdl2/render.scm index 5c3b9b0..94e115a 100644 --- a/sdl2/render.scm +++ b/sdl2/render.scm @@ -66,6 +66,7 @@ set-texture-alpha-mod! make-texture + update-texture delete-texture! surface->texture query-texture)) @@ -332,6 +333,21 @@ created with 'texture')" (sdl-error "make-texture" "Failed to create texture") (wrap-texture ptr)))) +(define (update-texture texture rect pixels pitch) + "Update the subsection of TEXTURE defined by RECT with new pixel +data in the PIXELS bytevector. PITCH represents the number of bytes +in a row of pixel data, including any padding between rows. This is a +fairly slow process: Better to use the lock/unlock mechanism in +streaming textures." + (let ((ret (ffi:sdl-update-texture + (unwrap-texture texture) + ((@@ (sdl2 rect) unwrap-rect) rect) + (bytevector->pointer pixels) + pitch))) + (if (> 0 ret) + (sdl-error "update-texture" "failed to update texture") + ret))) + (define (surface->texture renderer surface) "Convert SURFACE to a texture suitable for RENDERER." (let ((ptr (ffi:sdl-create-texture-from-surface |