summaryrefslogtreecommitdiff
path: root/sly/game.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-09-21 19:44:10 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-09-21 19:48:44 -0400
commit46544b7dba0081f22e686f70c606a338c7fa52dd (patch)
tree9688f43493606f7b0e4da8784a7804cc32f128eb /sly/game.scm
parentb7bf25020f146331d161d86ef30df31d2959a8dc (diff)
render: Reimplement rendering engine using functional combinators.
Warning: This is a huge commit. I completely gutted the old scene graph and replaced it with a somewhat monadic rendering combinator module instead. The interface remains purely functional, but replaces the <model> data type with procedures in the rendering monad instead. This opens the door for rendering *anything*, not just meshes. Now I can implement particle systems and other non-static things.
Diffstat (limited to 'sly/game.scm')
-rw-r--r--sly/game.scm18
1 files changed, 8 insertions, 10 deletions
diff --git a/sly/game.scm b/sly/game.scm
index 7e4a79c..ef92e90 100644
--- a/sly/game.scm
+++ b/sly/game.scm
@@ -35,7 +35,6 @@
#:use-module (sly math vector)
#:use-module (sly window)
#:use-module (sly render)
- #:use-module (sly render scene)
#:export (draw-hook
after-game-loop-error-hook
run-game-loop
@@ -67,13 +66,13 @@ for the given STACK and error KEY with additional arguments ARGS."
(tick-rate 60)
(max-ticks-per-frame 4))
"Run the game loop. SCENE is a signal which contains the current
-scene to render. FRAME-RATE specifies the optimal number of frames to
-draw SCENE per second. TICK-RATE specifies the optimal game logic
-updates per second. Both FRAME-RATE and TICK-RATE are 60 by default.
-MAX-TICKS-PER-FRAME is the maximum number of times the game loop will
-update game state in a single frame. When this upper bound is reached
-due to poor performance, the game will start to slow down instead of
-becoming completely unresponsive and possibly crashing."
+scene renderer procedure. FRAME-RATE specifies the optimal number of
+frames to draw SCENE per second. TICK-RATE specifies the optimal game
+logic updates per second. Both FRAME-RATE and TICK-RATE are 60 by
+default. MAX-TICKS-PER-FRAME is the maximum number of times the game
+loop will update game state in a single frame. When this upper bound
+is reached due to poor performance, the game will start to slow down
+instead of becoming completely unresponsive and possibly crashing."
(let ((tick-interval (interval tick-rate))
(frame-interval (interval frame-rate))
(gfx (make-graphics)))
@@ -84,8 +83,7 @@ becoming completely unresponsive and possibly crashing."
(gl-viewport 0 0 (vx size) (vy size)))
(gl-clear (clear-buffer-mask color-buffer depth-buffer))
(run-hook draw-hook dt alpha)
- (with-graphics gfx
- (draw-scene (signal-ref scene) gfx))
+ (with-graphics gfx ((signal-ref scene) gfx))
(SDL:gl-swap-buffers))
(define (update lag)