diff options
-rw-r--r-- | chickadee/render/gpu.scm | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/chickadee/render/gpu.scm b/chickadee/render/gpu.scm index 1a09a6a..66510fc 100644 --- a/chickadee/render/gpu.scm +++ b/chickadee/render/gpu.scm @@ -114,32 +114,39 @@ from the GPU's memory." (define (make-gpu gl-context) (let ((textures (make-vector 32)) - (apply-texture (@@ (chickadee render texture) apply-texture))) + ;; Lazily resolve bindings to avoid circular dependencies. + (blend-module (resolve-interface '(chickadee render blend))) + (buffer-module (resolve-interface '(chickadee render buffer))) + (framebuffer-module (resolve-interface '(chickadee render framebuffer))) + (shader-module (resolve-interface '(chickadee render shader))) + (texture-module (resolve-interface '(chickadee render texture))) + (viewport-module (resolve-interface '(chickadee render viewport)))) ;; Create state for 32 texture units. (let loop ((i 0)) (when (< i 32) (vector-set! textures i - (make-gpu-state (lambda (texture) - (apply-texture i texture)) - (@ (chickadee render texture) null-texture))) + (let ((apply-texture (module-ref texture-module 'apply-texture))) + (make-gpu-state (lambda (texture) + (apply-texture i texture)) + (module-ref texture-module 'null-texture)))) (loop (+ i 1)))) (%make-gpu gl-context ;; Use @ and @@ to avoid circular module dependencies. - (make-gpu-state (@@ (chickadee render blend) apply-blend-mode) + (make-gpu-state (module-ref blend-module 'apply-blend-mode) 'replace) - (make-gpu-state (@@ (chickadee render blend) apply-depth-test) + (make-gpu-state (module-ref blend-module 'apply-depth-test) #f) - (make-gpu-state (@@ (chickadee render framebuffer) apply-framebuffer) - (@ (chickadee render framebuffer) null-framebuffer)) - (make-gpu-state (@@ (chickadee render shader) apply-shader) - (@ (chickadee render shader) null-shader)) + (make-gpu-state (module-ref framebuffer-module 'apply-framebuffer) + (module-ref framebuffer-module 'null-framebuffer)) + (make-gpu-state (module-ref shader-module 'apply-shader) + (module-ref shader-module 'null-shader)) textures - (make-gpu-state (@@ (chickadee render buffer) apply-buffer) - (@ (chickadee render buffer) null-buffer)) - (make-gpu-state (@@ (chickadee render buffer) apply-vertex-array) - (@ (chickadee render buffer) null-vertex-array)) - (make-gpu-state (@@ (chickadee render viewport) apply-viewport) - (@ (chickadee render viewport) null-viewport))))) + (make-gpu-state (module-ref buffer-module 'apply-buffer) + (module-ref buffer-module 'null-buffer)) + (make-gpu-state (module-ref buffer-module 'apply-vertex-array) + (module-ref buffer-module 'null-vertex-array)) + (make-gpu-state (module-ref viewport-module 'apply-viewport) + (module-ref viewport-module 'null-viewport))))) (define-syntax-rule (define-gpu-getter name ref) (define (name gpu) |