From f00ab87113842bce26f7022f8d074608c8c140df Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 2 Jan 2016 07:32:42 -0500 Subject: render: Add render/signal macro. * sly/render.scm (render/signal): New syntax. --- .dir-locals.el | 3 ++- sly/render.scm | 10 +++++++++- 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)))) -- cgit v1.2.3