summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-01-02 07:32:42 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-01-02 07:32:42 -0500
commitf00ab87113842bce26f7022f8d074608c8c140df (patch)
tree9400bbd969ac4553cd7455c8c705734a59d38aca
parent1c958fb668cb316245ab9f53833960c28fda0f59 (diff)
render: Add render/signal macro.
* sly/render.scm (render/signal): New syntax.
-rw-r--r--.dir-locals.el3
-rw-r--r--sly/render.scm10
2 files changed, 11 insertions, 2 deletions
diff --git a/.dir-locals.el b/.dir-locals.el
index f8534e6..cd94516 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -21,4 +21,5 @@
(eval . (put 'with-vertex-buffer 'scheme-indent-function 1))
(eval . (put 'with-sprite-batch 'scheme-indent-function 2))
(eval . (put 'uniform-let 'scheme-indent-function 1))
- (eval . (put 'call-with-surface 'scheme-indent-function 1)))))
+ (eval . (put 'call-with-surface 'scheme-indent-function 1))
+ (eval . (put 'render/signal 'scheme-indent-function 1)))))
diff --git a/sly/render.scm b/sly/render.scm
index 875f7c1..6bc917b 100644
--- a/sly/render.scm
+++ b/sly/render.scm
@@ -31,6 +31,7 @@
#:use-module (gl)
#:use-module (gl enums)
#:use-module (gl low-level)
+ #:use-module (sly signal)
#:use-module (sly wrappers gl)
#:use-module ((sly math transform) #:prefix t:)
#:use-module (sly render color)
@@ -117,7 +118,8 @@
clear-screen
uniform-let
with-color
- render-mesh))
+ render-mesh
+ render/signal))
;;;
;;; Transformation matrix stack.
@@ -524,3 +526,9 @@ COLOR and applies RENDERER."
`((mvp ,(graphics-model-view-transform gfx))
(texture? ,(not (texture-null? (graphics-texture gfx)))))
draw-graphics-mesh!)))))
+
+(define-syntax-rule (render/signal ((name signal) ...) renderer)
+ "Evaluate RENDERER whenever a bound signal changes."
+ (let ((s (signal-let ((name signal) ...) renderer)))
+ (lambda (gfx)
+ ((signal-ref s) gfx))))