render: Add SDL_RenderDrawPoints binding.
authorPierre-Antoine Rouby <contact@parouby.fr>
Wed, 29 May 2019 20:43:27 +0000 (22:43 +0200)
committerDavid Thompson <dthompson2@worcester.edu>
Fri, 31 May 2019 13:51:18 +0000 (09:51 -0400)
* sdl2/bindings.scm (sdl-render-draw-points): New procedure.
* sdl2/render.scm (render-draw-points): New procedure.
* doc/api.texi (Rendering): Document it.

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

index 0a154ae..b692725 100644 (file)
@@ -1066,6 +1066,11 @@ Draw a point at (@var{x}, @var{y}) on the current rendering target
 of @var{renderer}.
 @end deffn
 
+@deffn {Procedure} render-draw-points renderer points
+Draw a multiple points from @var{points} on the current rendering
+target of @var{renderer}.
+@end deffn
+
 @deffn {Procedure} surface->texture renderer surface
 Convert @var{surface} to a texture suitable for @var{renderer}.
 @end deffn
index c382a45..bf8db7a 100644 (file)
@@ -255,6 +255,9 @@ RETURN-TYPE and accept arguments of ARG-TYPES."
 (define-foreign sdl-render-draw-point
   int "SDL_RenderDrawPoint" (list '* int int))
 
+(define-foreign sdl-render-draw-points
+  int "SDL_RenderDrawPoints" (list '* '* int))
+
 \f
 ;;;
 ;;; Events
index 91236c6..326745f 100644 (file)
@@ -40,6 +40,7 @@
             set-render-draw-color
             render-draw-line
             render-draw-point
+            render-draw-points
 
             delete-texture!
             surface->texture))
@@ -118,6 +119,21 @@ color."
   "Draw point on RENDERER."
   (ffi:sdl-render-draw-point (unwrap-renderer renderer) x y))
 
+(define (render-draw-points renderer points)
+  "Draw POINTS on RENDERER."
+  (define (fill-bv bv l n)
+    (match l
+      (() bv)
+      (((x y) . r)
+       (s32vector-set! bv n x)
+       (s32vector-set! bv (+ n 1) y)
+       (fill-bv bv r (+ 2 n)))))
+  (let* ((count (length points))
+         (bv (fill-bv (make-s32vector (* count 2)) points 0)))
+    (ffi:sdl-render-draw-points (unwrap-renderer renderer)
+                                (bytevector->pointer bv)
+                                count)))
+
 \f
 ;;;
 ;;; Texture