summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-09-10 21:27:25 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-09-10 21:30:19 -0400
commit372abd79211d84fa9a9b4e7cd90925109614a730 (patch)
treeb33fc1803c20e09c2a8e9571da20fc12ef6d3e5a
parentcbf59a78d1a85cfc92644615a56a18cf6b054604 (diff)
render: texture: Add flip? argument to make-texture.
* chickadee/render/texture.scm (make-texture): Add #:flip? keyword argument.
-rw-r--r--chickadee/render/texture.scm16
1 files changed, 11 insertions, 5 deletions
diff --git a/chickadee/render/texture.scm b/chickadee/render/texture.scm
index 4214c70..e37e4ec 100644
--- a/chickadee/render/texture.scm
+++ b/chickadee/render/texture.scm
@@ -139,6 +139,7 @@
(gpu-state-set! (vector-ref *texture-states* n) texture))
(define* (make-texture pixels width height #:key
+ flip?
(min-filter 'linear)
(mag-filter 'linear)
(wrap-s 'repeat)
@@ -146,10 +147,13 @@
(format 'rgba))
"Translate the bytevector PIXELS into an OpenGL texture with
dimensions WIDTHxHEIGHT where each pixel is in 32-bit RGBA format.
-The generated texture uses MIN-FILTER for downscaling and MAG-FILTER
-for upscaling. WRAP-S and WRAP-T are symbols that control how texture
-access is handled for texture coordinates outside the [0, 1] range.
-Allowed symbols are: repeat (the default), clamp, clamp-to-border,
+The first pixe lin PIXELS corresponds to the upper-left corner of the
+image. If this is not the case and the first pixel corresponds to the
+lower-left corner of the image, set FLIP? to #t. The generated
+texture uses MIN-FILTER for downscaling and MAG-FILTER for upscaling.
+WRAP-S and WRAP-T are symbols that control how texture access is
+handled for texture coordinates outside the [0, 1] range. Allowed
+symbols are: repeat (the default), clamp, clamp-to-border,
clamp-to-edge. FORMAT specifies the pixel format. Currently only
32-bit RGBA format is supported."
(define (gl-wrap mode)
@@ -164,7 +168,9 @@ clamp-to-edge. FORMAT specifies the pixel format. Currently only
min-filter mag-filter wrap-s wrap-t
0 0 width height
(make-rect 0.0 0.0 width height)
- (make-rect 0.0 0.0 1.0 1.0)))))
+ (if flip?
+ (make-rect 1.0 1.0 -1.0 -1.0)
+ (make-rect 0.0 0.0 1.0 1.0))))))
(texture-set! 0 texture)
(gl-texture-parameter (texture-target texture-2d)
(texture-parameter-name texture-min-filter)