diff options
-rw-r--r-- | sly/render/sprite-batch.scm | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/sly/render/sprite-batch.scm b/sly/render/sprite-batch.scm index 8b59cb3..f4c3245 100644 --- a/sly/render/sprite-batch.scm +++ b/sly/render/sprite-batch.scm @@ -96,7 +96,8 @@ (when (texture-null? (sprite-batch-texture batch)) (set-sprite-batch-texture! batch texture)) - (let ((size (sprite-batch-size batch))) + (let ((size (sprite-batch-size batch)) + (rect* ((@@ (sly math rect) rect->bytevector) rect))) (let ((index-offset (* size 6)) (index-vertex-offset (* size 4)) (vertex-offset (* size 12)) ; 4 vertices, 3 floats per vertex @@ -111,10 +112,15 @@ (t1 (texture-t1 texture)) (s2 (texture-s2 texture)) (t2 (texture-t2 texture)) - (top (rect-top rect)) - (bottom (rect-bottom rect)) - (left (rect-left rect)) - (right (rect-right rect))) + (rx (f64vector-ref rect* 0)) + (ry (f64vector-ref rect* 1)) + (rw (f64vector-ref rect* 2)) + (rh (f64vector-ref rect* 3)) + ;; (top (rect-top rect)) + ;; (bottom (rect-bottom rect)) + ;; (left (rect-left rect)) + ;; (right (rect-right rect)) + ) ;; Add indices. (u32vector-set! index-buffer index-offset index-vertex-offset) @@ -126,20 +132,20 @@ ;; Add vertices. ;; Bottom-left - (f32vector-set! pos-buffer vertex-offset left) - (f32vector-set! pos-buffer (+ vertex-offset 1) bottom) + (f32vector-set! pos-buffer vertex-offset rx) + (f32vector-set! pos-buffer (+ vertex-offset 1) ry) (f32vector-set! pos-buffer (+ vertex-offset 2) 0.0) ;; Bottom-right - (f32vector-set! pos-buffer (+ vertex-offset 3) right) - (f32vector-set! pos-buffer (+ vertex-offset 4) bottom) + (f32vector-set! pos-buffer (+ vertex-offset 3) (+ rx rw)) + (f32vector-set! pos-buffer (+ vertex-offset 4) ry) (f32vector-set! pos-buffer (+ vertex-offset 5) 0.0) ;; Top-right - (f32vector-set! pos-buffer (+ vertex-offset 6) right) - (f32vector-set! pos-buffer (+ vertex-offset 7) top) + (f32vector-set! pos-buffer (+ vertex-offset 6) (+ rx rw)) + (f32vector-set! pos-buffer (+ vertex-offset 7) (+ ry rh)) (f32vector-set! pos-buffer (+ vertex-offset 8) 0.0) ;; Top-left - (f32vector-set! pos-buffer (+ vertex-offset 9) left) - (f32vector-set! pos-buffer (+ vertex-offset 10) top) + (f32vector-set! pos-buffer (+ vertex-offset 9) rx) + (f32vector-set! pos-buffer (+ vertex-offset 10) (+ ry rh)) (f32vector-set! pos-buffer (+ vertex-offset 11) 0.0) ;; Add texture coordinates. |