diff options
author | David Thompson <dthompson2@worcester.edu> | 2021-03-14 10:30:49 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2021-03-14 10:30:49 -0400 |
commit | 6c652d155fe6af7af0d151c5187b8c4ed8abba2b (patch) | |
tree | f2348002e504c5a1cf19c721b2736ce46d962401 /chickadee/graphics/sprite.scm | |
parent | 0c017ecd3491d062d63ffa2e87d9198f5fd392b2 (diff) |
graphics: Rewrite with-graphics-state to use state specs.
Treating the names inside the let-like form as just symbols caused
numerous bugs where a program would crash because it was trying to set
graphics state that was never defined due to the relevant module never
being imported. By changing with-graphics-state to require passing in
the <graphics-state-spec> object, much like how parameterize works
with parameter objects, it completely eliminates this type of bug. If
the module containing the spec variable isn't imported, there will be
an undefined variable error thrown early on.
Additionally, graphics state objects needed to have a stack added to
them to track previous values so that with-graphics-state could
restore them later. The old trick of using let to stash the previous
values no longer worked with the new macro implementation.
Diffstat (limited to 'chickadee/graphics/sprite.scm')
-rw-r--r-- | chickadee/graphics/sprite.scm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/chickadee/graphics/sprite.scm b/chickadee/graphics/sprite.scm index cdb0ed9..76ee94a 100644 --- a/chickadee/graphics/sprite.scm +++ b/chickadee/graphics/sprite.scm @@ -130,8 +130,8 @@ void main (void) { (x2 y2 s2 t1) (x1 y2 s1 t1)) (geometry-index-append! geometry 0 3 2 0 2 1))) - (with-graphics-state ((blend-mode blend-mode) - (texture-0 texture)) + (with-graphics-state ((g:blend-mode blend-mode) + (g:texture-0 texture)) (shader-apply shader (geometry-vertex-array geometry) #:tint tint @@ -341,8 +341,8 @@ may be specified via the TEXTURE-REGION argument." (mvp (graphics-variable-ref sprite-mvp-matrix))) (sprite-batch-flush! batch) (matrix4-mult! mvp matrix (current-projection)) - (with-graphics-state ((blend-mode blend-mode) - (texture-0 (sprite-batch-texture batch))) + (with-graphics-state ((g:blend-mode blend-mode) + (g:texture-0 (sprite-batch-texture batch))) (let ((geometry (sprite-batch-geometry batch))) (shader-apply* shader (geometry-vertex-array geometry) |