diff options
author | David Thompson <dthompson2@worcester.edu> | 2016-01-11 08:37:42 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-01-12 08:38:44 -0500 |
commit | d21b67eaad50c9389e1ad83cc595d2e77783942c (patch) | |
tree | fb2642a4c14f63d01a6d1fe193676b7ea024d866 | |
parent | 3c349c76e44ae4f5789a2f9e68f6ad260d212a30 (diff) |
render: Add alpha value to render context.
Necessary for interpolating moving objects to avoid temporal aliasing.
* sly/render.scm (<graphics>)[alpha]: New field.
(graphics-alpha, set-graphics-alpha!): New procedure.
* sly/game.scm (run-game-loop): Set the frame's alpha value before each
render call.
-rw-r--r-- | sly/game.scm | 4 | ||||
-rw-r--r-- | sly/render.scm | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/sly/game.scm b/sly/game.scm index 5f1a1ec..722bfc0 100644 --- a/sly/game.scm +++ b/sly/game.scm @@ -84,7 +84,9 @@ instead of 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 ((signal-ref scene) gfx)) + (with-graphics gfx + (set-graphics-alpha! gfx alpha) + ((signal-ref scene) gfx)) (swap-window)) (define (update lag) diff --git a/sly/render.scm b/sly/render.scm index 6bc917b..deac23a 100644 --- a/sly/render.scm +++ b/sly/render.scm @@ -57,6 +57,8 @@ set-graphics-framebuffer! graphics-viewport set-graphics-viewport! + graphics-alpha + set-graphics-alpha! graphics-model-view-transform graphics-model-view-mul! graphics-model-view-identity! @@ -177,7 +179,8 @@ (viewport graphics-viewport %set-graphics-viewport!) (projection graphics-projection) (model-view graphics-model-view) - (uniforms graphics-uniforms set-graphics-uniforms!)) + (uniforms graphics-uniforms set-graphics-uniforms!) + (alpha graphics-alpha set-graphics-alpha!)) (define (graphics-uniform-ref gfx uniform) (hashq-ref (graphics-uniforms gfx) uniform)) |