summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/sprite-batch.scm22
1 files changed, 12 insertions, 10 deletions
diff --git a/examples/sprite-batch.scm b/examples/sprite-batch.scm
index c31ffbf..4bddf8f 100644
--- a/examples/sprite-batch.scm
+++ b/examples/sprite-batch.scm
@@ -14,6 +14,7 @@
(statprof))
(define texture #f)
+(define batch #f)
(define start-time (sdl-ticks))
(define avg-frame-time 16)
(define num-sprites 5000)
@@ -37,6 +38,7 @@
(define (load)
(set! *random-state* (random-state-from-platform))
(set! texture (load-image "images/shot.png"))
+ (set! batch (make-sprite-batch texture #:capacity 8000))
(script
(forever
(sleep 60)
@@ -44,13 +46,14 @@
(define stats-text-pos (vec2 4.0 464.0))
(define (draw alpha)
- (with-batched-sprites
- (for-each (match-lambda
- ((r v)
- (set-rect-x! r (+ (rect-x r) (vec2-x v)))
- (set-rect-y! r (+ (rect-y r) (vec2-y v)))
- (draw-sprite* texture r matrix)))
- sprites))
+ (sprite-batch-clear! batch)
+ (for-each (match-lambda
+ ((r v)
+ (set-rect-x! r (+ (rect-x r) (vec2-x v)))
+ (set-rect-y! r (+ (rect-y r) (vec2-y v)))
+ (sprite-batch-add* batch r matrix)))
+ sprites)
+ (draw-sprite-batch batch)
(draw-text stats-text stats-text-pos)
(let ((current-time (sdl-ticks)))
(set! avg-frame-time
@@ -61,6 +64,5 @@
(define (update dt)
(update-agenda 1))
-(gcprof
- (lambda ()
- (run-game #:load load #:draw draw #:update update)))
+(run-game #:load load #:draw draw #:update update
+ #:window-title "sprite batch stress test")