From 6c652d155fe6af7af0d151c5187b8c4ed8abba2b Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 14 Mar 2021 10:30:49 -0400 Subject: 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 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. --- chickadee.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chickadee.scm') diff --git a/chickadee.scm b/chickadee.scm index 489fd0b..a8251f3 100644 --- a/chickadee.scm +++ b/chickadee.scm @@ -369,7 +369,7 @@ border is disabled, otherwise it is enabled.") ;; Free any GPU resources that have been GC'd. (graphics-engine-reap! gfx)) (define (render-sdl-opengl alpha) - (with-graphics-state! ((viewport (atomic-box-ref default-viewport))) + (with-graphics-state! ((g:viewport (atomic-box-ref default-viewport))) (clear-viewport) (with-projection (atomic-box-ref default-projection) (draw alpha))) -- cgit v1.2.3