render: Add SDL_DestroyTexture binding.
authorPierre-Antoine Rouby <contact@parouby.fr>
Sun, 26 May 2019 11:45:00 +0000 (13:45 +0200)
committerDavid Thompson <dthompson2@worcester.edu>
Tue, 28 May 2019 00:41:01 +0000 (20:41 -0400)
* sdl2/bindings.scm (sdl-destroy-texture): New procedure.
* sdl2/render.scm (delete-texture!): New procedure.
* doc/api.texi (Renderer): Document it.

doc/api.texi
sdl2/bindings.scm
sdl2/render.scm

index 00fe3a8..0a154ae 100644 (file)
@@ -1070,6 +1070,10 @@ of @var{renderer}.
 Convert @var{surface} to a texture suitable for @var{renderer}.
 @end deffn
 
+@deffn {Procedure} delete-texture! texture
+Free the memory used by @var{texture}.
+@end deffn
+
 @node Images
 @section Images
 
index e81abf7..c382a45 100644 (file)
@@ -243,6 +243,9 @@ RETURN-TYPE and accept arguments of ARG-TYPES."
 (define-foreign sdl-create-texture-from-surface
   '* "SDL_CreateTextureFromSurface" '(* *))
 
+(define-foreign sdl-destroy-texture
+  void "SDL_DestroyTexture" '(*))
+
 (define-foreign sdl-set-render-draw-color
   int "SDL_SetRenderDrawColor" (list '* uint8 uint8 uint8 uint8))
 
index 9e4bf57..187c650 100644 (file)
@@ -41,6 +41,7 @@
             render-draw-line
             render-draw-point
 
+            destroy-texture!
             surface->texture))
 
 \f
@@ -138,6 +139,9 @@ color."
         (sdl-error "surface->texture" "failed to convert surface to texture")
         (wrap-texture ptr))))
 
+(define (delete-texture! texture)
+  "Free the memory used by TEXTURE."
+  (ffi:sdl-destroy-texture (unwrap-texture texture)))
 
 (define* (render-copy renderer texture
                       #:key (angle 0) srcrect dstrect center)