summaryrefslogtreecommitdiff
path: root/sdl2.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-12-17 09:06:58 -0500
committerDavid Thompson <dthompson2@worcester.edu>2015-12-17 09:08:07 -0500
commit082243021181e6b77be164683d6b0812f6666f54 (patch)
treeccdf81f806e75e580082edb770808f2d5d305932 /sdl2.scm
parent1403e4a67989d627fe84b6e6beeec641c1d7d49e (diff)
Add color type.
* sdl2/bindings.scm (sdl-color): New variable. * sdl2.scm (<color>): New record type. (make-color, color?, color-r, color-g, color-b, color-a, color->struct): New procedures.
Diffstat (limited to 'sdl2.scm')
-rw-r--r--sdl2.scm26
1 files changed, 25 insertions, 1 deletions
diff --git a/sdl2.scm b/sdl2.scm
index 74839fe..3541596 100644
--- a/sdl2.scm
+++ b/sdl2.scm
@@ -26,6 +26,7 @@
(define-module (sdl2)
#:use-module (ice-9 match)
#:use-module (srfi srfi-4)
+ #:use-module (srfi srfi-9)
#:use-module (system foreign)
#:use-module ((sdl2 bindings) #:prefix ffi:)
#:export (sdl-error-string
@@ -33,7 +34,15 @@
sdl-version
sdl-init
sdl-quit
- sdl-ticks))
+ sdl-ticks
+
+ <color>
+ make-color
+ color?
+ color-r
+ color-g
+ color-b
+ color-a))
(define %default-init-flags
'(timer audio video haptic game-controller events))
@@ -83,3 +92,18 @@ upon all exit conditions."
"Return the number of milliseconds since the SDL library
initialization."
(ffi:sdl-get-ticks))
+
+;; SDL_Color
+(define-record-type <color>
+ (make-color r g b a)
+ color?
+ (r color-r)
+ (g color-g)
+ (b color-b)
+ (a color-a))
+
+(define (color->struct color)
+ "Convert COLOR into a foreign struct."
+ (match color
+ (($ <color> r g b a)
+ (make-c-struct ffi:sdl-color (list r g b a)))))