summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2024-04-26 07:57:16 -0400
committerDavid Thompson <dthompson2@worcester.edu>2024-04-26 07:57:16 -0400
commitf31dd55460214cbde4d67b7f774bece4faa313c7 (patch)
tree65aaa471a3e7bb145ba40fe00f8e2a86186a8917
parent29b5ce542a63ff179d674f6bc91442899da68c0c (diff)
texture: Coerce args to images in load-cube-map.HEADmaster
-rw-r--r--chickadee/graphics/texture.scm20
1 files changed, 12 insertions, 8 deletions
diff --git a/chickadee/graphics/texture.scm b/chickadee/graphics/texture.scm
index 65b7300..952cfe0 100644
--- a/chickadee/graphics/texture.scm
+++ b/chickadee/graphics/texture.scm
@@ -437,6 +437,11 @@ by the bounding box RECT."
(pixbuf-color-key! pixbuf transparent-color))
pixbuf))
+(define (->image obj)
+ (match obj
+ ((? image?) obj)
+ ((? string?) (make-image obj))))
+
(define* (load-image image #:key
(min-filter 'nearest)
(mag-filter 'nearest)
@@ -448,8 +453,7 @@ by the bounding box RECT."
or a file name string. MIN-FILTER and MAG-FILTER describe the method
that should be used for minification and magnification. Valid values
are 'nearest and 'linear. By default, 'nearest is used."
- (let* ((image* (if (image? image) image (make-image image)))
- (pixbuf (%load-image image* transparent-color flip?)))
+ (let ((pixbuf (%load-image (->image image) transparent-color flip?)))
(pixbuf->texture pixbuf
#:min-filter min-filter
#:mag-filter mag-filter
@@ -459,12 +463,12 @@ are 'nearest and 'linear. By default, 'nearest is used."
(define* (load-cube-map #:key right left top bottom front back
(min-filter 'linear-mipmap-linear)
(mag-filter 'linear))
- (make-cube-map #:right (%load-image right #f #f)
- #:left (%load-image left #f #f)
- #:top (%load-image top #f #f)
- #:bottom (%load-image bottom #f #f)
- #:front (%load-image front #f #f)
- #:back (%load-image back #f #f)
+ (make-cube-map #:right (%load-image (->image right) #f #f)
+ #:left (%load-image (->image left) #f #f)
+ #:top (%load-image (->image top) #f #f)
+ #:bottom (%load-image (->image bottom) #f #f)
+ #:front (%load-image (->image front) #f #f)
+ #:back (%load-image (->image back) #f #f)
#:min-filter min-filter
#:mag-filter mag-filter))