diff options
-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)))) ;;; |