summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-05-22 20:02:27 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-05-22 20:18:20 -0400
commit1a315b9b0f46964016795d7d528753295903839f (patch)
tree9a0833b3fd2290eea2a2be98f26e8e17ef9e9cf6 /2d
parente74f4e6d4ffcbf3923c597e75acbc5f0260516f8 (diff)
Add load-shader-program procedure.
* 2d/shader.scm (load-shader-procedure): New procedure. * 2d/font.scm: * 2d/sprite.scm: Use it.
Diffstat (limited to '2d')
-rw-r--r--2d/font.scm12
-rw-r--r--2d/shader.scm5
-rw-r--r--2d/sprite.scm12
3 files changed, 15 insertions, 14 deletions
diff --git a/2d/font.scm b/2d/font.scm
index 0917e66..3f4674f 100644
--- a/2d/font.scm
+++ b/2d/font.scm
@@ -59,13 +59,11 @@
(define (enable-fonts)
(SDL:ttf-init)
(set! font-shader
- (make-shader-program
- (load-vertex-shader
- (string-append %pkgdatadir
- "/shaders/font-vertex.glsl"))
- (load-fragment-shader
- (string-append %pkgdatadir
- "/shaders/font-fragment.glsl")))))
+ (load-shader-program
+ (string-append %pkgdatadir
+ "/shaders/font-vertex.glsl")
+ (string-append %pkgdatadir
+ "/shaders/font-fragment.glsl"))))
(define-record-type <font>
(make-font ttf point-size)
diff --git a/2d/shader.scm b/2d/shader.scm
index d8b165e..0be977f 100644
--- a/2d/shader.scm
+++ b/2d/shader.scm
@@ -42,6 +42,7 @@
shader-type
shader-id
make-shader-program
+ load-shader-program
shader-program-id
shader-program?
shader-program-linked?
@@ -217,6 +218,10 @@ VERTEX-SHADER and FRAGMENT-SHADER."
shaders)
shader-program))
+(define (load-shader-program vertex-shader-file-name fragment-shader-file-name)
+ (make-shader-program (load-vertex-shader vertex-shader-file-name)
+ (load-fragment-shader fragment-shader-file-name)))
+
(define current-shader-program (make-parameter #f))
(define-syntax-rule (with-shader-program shader-program body ...)
diff --git a/2d/sprite.scm b/2d/sprite.scm
index c3dc4f1..39bc746 100644
--- a/2d/sprite.scm
+++ b/2d/sprite.scm
@@ -68,13 +68,11 @@
(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")))))
+ (load-shader-program
+ (string-append %pkgdatadir
+ "/shaders/sprite-vertex.glsl")
+ (string-append %pkgdatadir
+ "/shaders/sprite-fragment.glsl"))))
;; The <sprite> type represents a drawable object (texture,
;; texture-region, animation, etc.) with a given position, scale,