summaryrefslogtreecommitdiff
path: root/2d/sprite.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-07-06 16:42:16 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-07-06 16:42:16 -0400
commit9d6d69e8067a8f10e155b271021f78a3cf7e8609 (patch)
tree9672ab9e98292ace85ce47f6425108efa82f037e /2d/sprite.scm
parent29adec1693fd4dd8135e2b0ae9733eeb822978b0 (diff)
Add optional texture coordinate parameters to texture-quad and sprite-batch-draw.
Diffstat (limited to '2d/sprite.scm')
-rw-r--r--2d/sprite.scm13
1 files changed, 7 insertions, 6 deletions
diff --git a/2d/sprite.scm b/2d/sprite.scm
index bcf09b6..5a0cf00 100644
--- a/2d/sprite.scm
+++ b/2d/sprite.scm
@@ -187,8 +187,9 @@
;; TODO add transformation logic for scaling and rotating.
;; TODO add support for colors
;; TODO add support for different blending modes.
-(define (sprite-batch-draw batch texture x y center-x center-y
- width height scale-x scale-y rotation)
+(define* (sprite-batch-draw batch texture x y center-x center-y
+ width height scale-x scale-y rotation
+ #:optional (u 0) (v 0) (u2 1) (v2 1))
;; Render the batch when it's full or the texture changes.
(cond ((= (sprite-batch-size batch) (sprite-batch-max-size batch))
(sprite-batch-render batch))
@@ -204,19 +205,19 @@
(pack vertices base sprite-vertex
x y
1 1 1 1
- 0 0)
+ u v)
(pack vertices (+ base 1) sprite-vertex
x2 y
1 1 1 1
- 1 0)
+ u2 v)
(pack vertices (+ base 2) sprite-vertex
x2 y2
1 1 1 1
- 1 1)
+ u2 v2)
(pack vertices (+ base 3) sprite-vertex
x y2
1 1 1 1
- 0 1))
+ u v2))
;; Increment batch size
(set-sprite-batch-size! batch (1+ (sprite-batch-size batch))))