summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2017-10-14 22:13:22 -0400
committerDavid Thompson <dthompson2@worcester.edu>2017-10-14 22:13:22 -0400
commit4b216e910f562c790dd59ddea8398d60bc2bd1b0 (patch)
tree4cd286c9539aebff1e08a4e0a6ab6240000e0384
parent51ea61ab6273a710e9f7662bb0987a19e643562a (diff)
render: sprite: Fix sprite batch resizing.
* chickadee/render/sprite.scm (double-sprite-batch-size!): Get reference to bytevectors before unmapping old buffers.
-rw-r--r--chickadee/render/sprite.scm19
1 files changed, 11 insertions, 8 deletions
diff --git a/chickadee/render/sprite.scm b/chickadee/render/sprite.scm
index 1291687..5c4ecb4 100644
--- a/chickadee/render/sprite.scm
+++ b/chickadee/render/sprite.scm
@@ -174,9 +174,12 @@ void main (void) {
(= (sprite-batch-capacity batch) (sprite-batch-size batch)))
(define (double-sprite-batch-size! batch)
- (let ((old-index (sprite-batch-index-buffer batch))
- (old-verts (sprite-batch-position-buffer batch))
- (old-tex (sprite-batch-texture-buffer batch)))
+ (let* ((old-index (sprite-batch-index-buffer batch))
+ (old-verts (sprite-batch-position-buffer batch))
+ (old-tex (sprite-batch-texture-buffer batch))
+ (old-index-data (typed-buffer-data old-index))
+ (old-verts-data (typed-buffer-data old-verts))
+ (old-tex-data (typed-buffer-data old-tex)))
(unmap-typed-buffer! old-index)
(unmap-typed-buffer! old-verts)
(unmap-typed-buffer! old-tex)
@@ -186,12 +189,12 @@ void main (void) {
(new-verts (sprite-batch-position-buffer batch))
(new-tex (sprite-batch-texture-buffer batch)))
(define (copy from to)
- (bytevector-copy! (typed-buffer-data from) 0
+ (bytevector-copy! from 0
(typed-buffer-data to) 0
- (bytevector-length (typed-buffer-data from))))
- (copy old-index new-index)
- (copy old-verts new-verts)
- (copy old-tex new-tex))))
+ (bytevector-length from)))
+ (copy old-index-data new-index)
+ (copy old-verts-data new-verts)
+ (copy old-tex-data new-tex))))
(define (sprite-batch-reset! batch)
"Reset BATCH to size 0."