diff options
Diffstat (limited to 'sdl2')
-rw-r--r-- | sdl2/bindings.scm | 3 | ||||
-rw-r--r-- | sdl2/render.scm | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/sdl2/bindings.scm b/sdl2/bindings.scm index 5a63636..897a0dc 100644 --- a/sdl2/bindings.scm +++ b/sdl2/bindings.scm @@ -327,6 +327,9 @@ RETURN-TYPE and accept arguments of ARG-TYPES." (define-foreign sdl-set-texture-blend-mode int "SDL_SetTextureBlendMode" (list '* int)) +(define-foreign sdl-update-texture + int "SDL_UpdateTexture" (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 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 |