diff options
author | David Thompson <dthompson2@worcester.edu> | 2019-05-22 22:04:14 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2019-05-22 22:04:14 -0400 |
commit | 834c25dbbf705a5541bd83d97bf29f711087ddc4 (patch) | |
tree | 1f6dfcb72e434f71d4c887a89f29922bca203a60 | |
parent | 6e290c7daf9fb24cdd6e50954c5cce40f5102a27 (diff) |
render: sprite: Add draw-sprite-batch* procedure.
* chickadee/render/sprite.scm (draw-sprite-batch*): New procedure.
(draw-sprite-batch): Rewrite in terms of 'draw-sprite-batch*'.
-rw-r--r-- | chickadee/render/sprite.scm | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/chickadee/render/sprite.scm b/chickadee/render/sprite.scm index bbdc4fa..b6a8232 100644 --- a/chickadee/render/sprite.scm +++ b/chickadee/render/sprite.scm @@ -38,6 +38,7 @@ sprite-batch-clear! sprite-batch-add* sprite-batch-add! + draw-sprite-batch* draw-sprite-batch with-batched-sprites @@ -406,15 +407,35 @@ void main (void) { } "))) -(define* (draw-sprite-batch batch #:key (blend-mode 'alpha)) - "Render the contents of BATCH." - (sprite-batch-flush! batch) - (with-blend-mode blend-mode - (with-texture 0 (sprite-batch-texture batch) - (gpu-apply* (force batched-sprite-shader) - (sprite-batch-vertex-array batch) - (* (sprite-batch-size batch) 6) - #:mvp (current-projection))))) +(define draw-sprite-batch* + (let ((mvp (make-null-matrix4))) + (lambda* (batch matrix #:key (blend-mode 'alpha)) + "Render the contents of BATCH." + (sprite-batch-flush! batch) + (matrix4-mult! mvp matrix (current-projection)) + (with-blend-mode blend-mode + (with-texture 0 (sprite-batch-texture batch) + (gpu-apply* (force batched-sprite-shader) + (sprite-batch-vertex-array batch) + (* (sprite-batch-size batch) 6) + #:mvp mvp)))))) + +(define draw-sprite-batch + (let ((matrix (make-null-matrix4))) + (lambda* (batch + #:key + (position %null-vec2) + (origin %null-vec2) + (scale %default-scale) + (rotation 0.0) + (blend-mode 'alpha)) + "Render the contents of BATCH." + (matrix4-2d-transform! matrix + #:origin origin + #:position position + #:rotation rotation + #:scale scale) + (draw-sprite-batch* batch matrix #:blend-mode blend-mode)))) ;;; |