diff options
author | David Thompson <dthompson2@worcester.edu> | 2021-05-05 20:19:28 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2021-05-05 20:19:28 -0400 |
commit | 1fdb28d1f1b8743a05d8f5bf377d65c9c0d3ce64 (patch) | |
tree | 11d949bcbce99874ec3cd01c0cb624a3ec77c478 | |
parent | 14eebd305e1d04203070329f73f71e7556ce039d (diff) |
graphics: texture: Make vertical pixel flipping optional in load-image.
-rw-r--r-- | chickadee/graphics/texture.scm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/chickadee/graphics/texture.scm b/chickadee/graphics/texture.scm index 94ce546..dd2a6d8 100644 --- a/chickadee/graphics/texture.scm +++ b/chickadee/graphics/texture.scm @@ -245,7 +245,8 @@ HEIGHT, 32 bit color bytevector." (bytevector-copy! pixels source-start buffer target-start row-width))) buffer)) -(define (surface->texture surface min-filter mag-filter wrap-s wrap-t transparent-color) +(define (surface->texture surface min-filter mag-filter wrap-s wrap-t + transparent-color flip?) "Convert SURFACE, an SDL2 surface object, into a texture that uses the given MIN-FILTER and MAG-FILTER." ;; Convert to 32 bit RGBA color. @@ -266,7 +267,9 @@ the given MIN-FILTER and MAG-FILTER." (= g (bytevector-u8-ref pixels (+ i 1))) (= b (bytevector-u8-ref pixels (+ i 2)))) (bytevector-u8-set! pixels (+ i 3) 0))))) - (make-texture (flip-pixels-vertically pixels width height) + (make-texture (if flip? + (flip-pixels-vertically pixels width height) + pixels) width height #:min-filter min-filter #:mag-filter mag-filter @@ -278,7 +281,8 @@ the given MIN-FILTER and MAG-FILTER." (mag-filter 'nearest) (wrap-s 'repeat) (wrap-t 'repeat) - transparent-color) + transparent-color + (flip? #t)) "Load a texture from an image in FILE. MIN-FILTER and MAG-FILTER describe the method that should be used for minification and magnification. Valid values are 'nearest and 'linear. By default, @@ -286,7 +290,7 @@ magnification. Valid values are 'nearest and 'linear. By default, (sdl2:call-with-surface (sdl2:load-image file) (lambda (surface) (surface->texture surface min-filter mag-filter wrap-s wrap-t - transparent-color)))) + transparent-color flip?)))) ;;; |