summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-03-29 16:16:33 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-03-29 16:16:33 -0400
commit40bacd7e2ba29a1813a8fcd8070cf9ea4a9abca8 (patch)
tree357871d81758a8f878b303c5c814a38be79bad8a
parent2fd537d6ecaa428068ad0576cafcd1254e5e654f (diff)
Don't load sprite shaders upon importing (2d sprite) module.
* 2d/sprite.scm (sprite-shader): Set to #f initially. (enable-sprites): New procedure. * 2d/common.scm: Enable sprites.
-rw-r--r--2d/sprite.scm20
-rw-r--r--examples/common.scm3
2 files changed, 16 insertions, 7 deletions
diff --git a/2d/sprite.scm b/2d/sprite.scm
index 7c7b9c0..3b74fdb 100644
--- a/2d/sprite.scm
+++ b/2d/sprite.scm
@@ -41,7 +41,8 @@
#:use-module (2d vector2)
#:use-module (2d window)
#:use-module (2d wrappers gl)
- #:export (make-sprite
+ #:export (enable-sprites
+ make-sprite
sprite?
animated-sprite?
sprite-drawable
@@ -63,12 +64,17 @@
;;; Sprites
;;;
-(define sprite-shader
- (make-shader-program
- (load-vertex-shader (string-append %pkgdatadir
- "/shaders/sprite-vertex.glsl"))
- (load-fragment-shader (string-append %pkgdatadir
- "/shaders/sprite-fragment.glsl"))))
+(define sprite-shader #f)
+
+(define (enable-sprites)
+ (set! sprite-shader
+ (make-shader-program
+ (load-vertex-shader
+ (string-append %pkgdatadir
+ "/shaders/sprite-vertex.glsl"))
+ (load-fragment-shader
+ (string-append %pkgdatadir
+ "/shaders/sprite-fragment.glsl")))))
;; The <sprite> type represents a drawable object (texture,
;; texture-region, animation, etc.) with a given position, scale,
diff --git a/examples/common.scm b/examples/common.scm
index b9675eb..b26186a 100644
--- a/examples/common.scm
+++ b/examples/common.scm
@@ -21,9 +21,12 @@
(2d keyboard)
(2d repl)
(2d signal)
+ (2d sprite)
(2d window))
(open-window)
+(enable-sprites)
+
(add-hook! key-press-hook (lambda (key unicode)
(when (eq? key 'escape)
(quit-game))))