summaryrefslogtreecommitdiff
path: root/sdl2/surface.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-01-07 22:53:13 -0500
committerDavid Thompson <dthompson2@worcester.edu>2019-01-07 22:53:13 -0500
commit6b8bef2445f71bd777b41a94cb33558cbc5cd2fb (patch)
tree8f4bb5c8732ed786cdb84195c51c7b7036eb9e29 /sdl2/surface.scm
parent74448f9ac2ef9f8eb2e68639da7c966f4eb2d6e2 (diff)
surface: Add SDL_BlitSurface binding.
* sdl2/bindings.scm (sdl-blit-surface): New procedure. * sdl2/surface.scm (blit-surface): New procedure.
Diffstat (limited to 'sdl2/surface.scm')
-rw-r--r--sdl2/surface.scm17
1 files changed, 16 insertions, 1 deletions
diff --git a/sdl2/surface.scm b/sdl2/surface.scm
index bcdb588..a918bd7 100644
--- a/sdl2/surface.scm
+++ b/sdl2/surface.scm
@@ -63,7 +63,8 @@
surface-height
surface-pitch
surface-pixels
- convert-surface-format))
+ convert-surface-format
+ blit-surface))
;;;
@@ -434,3 +435,17 @@ Valid format types are:
(if (null-pointer? ptr)
(sdl-error "convert-surface-format" "failed to convert surface format")
(wrap-surface ptr))))
+
+(define (blit-surface src src-rect dst dst-rect)
+ "Blit the rectangle SRC-RECT from the surface SRC to DST-RECT of the
+surface DST."
+ (unless (zero?
+ (ffi:sdl-blit-surface (unwrap-surface src)
+ (if src-rect
+ ((@@ (sdl2 rect) unwrap-rect) src-rect)
+ %null-pointer)
+ (unwrap-surface dst)
+ (if dst-rect
+ ((@@ (sdl2 rect) unwrap-rect) dst-rect)
+ %null-pointer)))
+ (sdl-error "blit-surface" "failed to blit surface ~a to ~a" src dst)))