summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))