From 1425a0dc73f7fa37612b7a82f090e9b10ddebf25 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 1 Sep 2023 09:00:01 -0400 Subject: 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. --- examples/sprite-batch.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'examples/sprite-batch.scm') 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) -- cgit v1.2.3