summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))))