summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-06-28 16:16:06 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-08-25 19:33:07 -0400
commit5f9b31e2fa47e7a99216c0c8aa09a1d8d348a4f1 (patch)
tree38505ec402d417e672ca6d0ac50983a01173a846
parent7c8875683544f2111e2f4b41d50151243ad2fec2 (diff)
Add with-texture macro.
* 2d/texture.scm (with-texture): New macro.
-rw-r--r--sly/texture.scm11
1 files changed, 10 insertions, 1 deletions
diff --git a/sly/texture.scm b/sly/texture.scm
index bea005d..e4bd7cb 100644
--- a/sly/texture.scm
+++ b/sly/texture.scm
@@ -25,6 +25,7 @@
(define-module (sly texture)
#:use-module (srfi srfi-9)
#:use-module (gl)
+ #:use-module (gl low-level)
#:use-module (gl contrib packed-struct)
#:use-module (sly color)
#:use-module (sly helpers)
@@ -46,7 +47,8 @@
anchor-texture
texture-vertex
pack-texture-vertices
- draw-texture-vertices))
+ draw-texture-vertices
+ with-texture))
;;;
;;; Textures
@@ -205,6 +207,13 @@ texture."
(pack vertices (+ offset 2) texture-vertex width height s2 t2)
(pack vertices (+ offset 3) texture-vertex width 0 s2 t1))
+(define-syntax-rule (with-texture texture body ...)
+ (begin
+ (glBindTexture (texture-target texture-2d) (texture-id texture))
+ body
+ ...
+ (glBindTexture (texture-target texture-2d) 0)))
+
(define (draw-texture-vertices texture vertices size)
(let ((pointer-type (tex-coord-pointer-type float)))
(gl-enable-client-state (enable-cap vertex-array))