summaryrefslogtreecommitdiff
path: root/sly/game.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-12-22 14:35:44 -0500
committerDavid Thompson <dthompson2@worcester.edu>2015-12-22 16:28:18 -0500
commit8b9b5d371d1dc1c780e227ce9a555cf6c88a85c8 (patch)
treef1b6524f92aaa329667f08f4a010a7b5e6925ae8 /sly/game.scm
parent60d601cbb5eb142d01f880b5902329ada93fc91a (diff)
Upgrade to SDL2!
This commit is massive and crazy and I'm not going to do the usual GNU ChangeLog thing because it's just too much. Let's just be happy that the port is completed!
Diffstat (limited to 'sly/game.scm')
-rw-r--r--sly/game.scm13
1 files changed, 7 insertions, 6 deletions
diff --git a/sly/game.scm b/sly/game.scm
index b114ada..5f1a1ec 100644
--- a/sly/game.scm
+++ b/sly/game.scm
@@ -26,7 +26,8 @@
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
- #:use-module ((sdl sdl) #:prefix SDL:)
+ #:use-module (sdl2)
+ #:use-module ((sdl2 video) #:prefix sdl2:)
#:use-module (gl)
#:use-module (sly agenda)
#:use-module (sly event)
@@ -84,7 +85,7 @@ instead of becoming completely unresponsive and possibly crashing."
(gl-clear (clear-buffer-mask color-buffer depth-buffer))
(run-hook draw-hook dt alpha)
(with-graphics gfx ((signal-ref scene) gfx))
- (SDL:gl-swap-buffers))
+ (swap-window))
(define (update lag)
"Call the update callback. The update callback will be called as
@@ -108,7 +109,7 @@ leftover frame time LAG."
(define (frame-sleep time)
"Sleep for the remainder of the frame that started at TIME."
(let ((t (- (+ time frame-interval)
- (SDL:get-ticks))))
+ (sdl-ticks))))
(usleep (max 0 (* t 1000)))))
(define (process-frame previous-time lag)
@@ -117,7 +118,7 @@ PREVIOUS-TIME to the current time, and updating using a game tick
accumulator initialized to LAG. Returns a timestamp to be used as the
starting point of the next delta time calculation and the leftover
time in the game tick accumulator."
- (let* ((current-time (SDL:get-ticks))
+ (let* ((current-time (sdl-ticks))
(dt (- current-time previous-time)))
(catch #t
(lambda ()
@@ -134,7 +135,7 @@ time in the game tick accumulator."
(run-hook after-game-loop-error-hook)
;; An unknown amount of time has passed since running the
;; hook, so let's start with a fresh timer.
- (values (SDL:get-ticks) 0))))
+ (values (sdl-ticks) 0))))
(lambda (key . args)
;; Strip out 3 stack frames to get to the frame where the
;; error happened. The stripped frames include the throw
@@ -156,7 +157,7 @@ milliseconds of the last iteration of the game loop."
(lambda (signum)
(stop-game-loop)))
;; Let's play!
- (game-loop (SDL:get-ticks) 0))
+ (game-loop (sdl-ticks) 0))
(lambda (cont callback)
(when (procedure? callback)
(callback cont))))))