summaryrefslogtreecommitdiff
path: root/examples/sprite-batch.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-09-01 09:00:01 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-11-08 21:35:34 -0500
commit1425a0dc73f7fa37612b7a82f090e9b10ddebf25 (patch)
tree97de459a6b021c7abb04944cdde512efe5909bd4 /examples/sprite-batch.scm
parentd969c19756227899b39967989fa971fa3452e872 (diff)
First pass of rendering engine rewrite.
The (chickadee graphics gpu) module now handles most of the low-level OpenGL object creation/deletion/binding. The (chickadee graphics engine) module handles the with-graphics-state stuff via a render context object. There's lots of stuff that isn't great, but it's the first step towards a graphics backend agnostic rendering layer.
Diffstat (limited to 'examples/sprite-batch.scm')
-rw-r--r--examples/sprite-batch.scm16
1 files changed, 12 insertions, 4 deletions
diff --git a/examples/sprite-batch.scm b/examples/sprite-batch.scm
index e62d1e4..cf79565 100644
--- a/examples/sprite-batch.scm
+++ b/examples/sprite-batch.scm
@@ -3,6 +3,7 @@
(chickadee math rect)
(chickadee math vector)
(chickadee graphics color)
+ (chickadee graphics path)
(chickadee graphics sprite)
(chickadee graphics text)
(chickadee graphics texture)
@@ -28,22 +29,28 @@
(define matrix (make-identity-matrix4))
(define (stats-message)
- (format #f "sprites: ~d fps: ~1,2f"
+ (format #f "sprites: ~d fps: ~1,2f"
num-sprites
(/ 1.0 avg-frame-time)))
-
+(define stats-text-pos (vec2 8.0 462.0))
(define stats-text (stats-message))
+(define stats-background
+ (with-style ((fill-color tango-light-plum))
+ (fill
+ (rounded-rectangle (vec2- stats-text-pos (vec2 4.0 4.0))
+ 212.0 18.0 #:radius 4.0))))
+(define stats-canvas (make-empty-canvas))
(define (load)
(set! *random-state* (random-state-from-platform))
(set! texture (load-image "images/shot.png"))
(set! batch (make-sprite-batch texture #:capacity num-sprites))
+ (set-canvas-painter! stats-canvas stats-background)
(script
(forever
(sleep 60)
(set! stats-text (pk 'stats (stats-message))))))
-(define stats-text-pos (vec2 4.0 464.0))
(define (draw alpha)
(sprite-batch-clear! batch)
(for-each (match-lambda
@@ -53,7 +60,8 @@
(sprite-batch-add* batch r matrix)))
sprites)
(draw-sprite-batch batch)
- (draw-text stats-text stats-text-pos #:color black)
+ (draw-canvas stats-canvas)
+ (draw-text stats-text stats-text-pos #:color tango-aluminium-6)
(let ((current-time (elapsed-time)))
(set! avg-frame-time
(+ (* (- current-time start-time) 0.1)