summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-05-22 19:29:05 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-05-22 20:04:12 -0400
commite74f4e6d4ffcbf3923c597e75acbc5f0260516f8 (patch)
treef90d188878571ecbe6dd4a49a049c89d1b281b5b
parent5b21c411d3723e441d97fd1a2b93b32b516cf3e6 (diff)
Add explicit vertex/fragment shader parameters to make-shader-program.
* 2d/shader.scm (make-shader-program): Change parameter list. (vertex-shader?, fragment-shader?): New procedures.
-rw-r--r--2d/shader.scm21
1 files changed, 18 insertions, 3 deletions
diff --git a/2d/shader.scm b/2d/shader.scm
index 094b929..d8b165e 100644
--- a/2d/shader.scm
+++ b/2d/shader.scm
@@ -36,6 +36,8 @@
load-vertex-shader
load-fragment-shader
shader?
+ vertex-shader?
+ fragment-shader?
shader-compiled?
shader-type
shader-id
@@ -76,6 +78,14 @@
(type shader-type)
(id shader-id))
+(define (vertex-shader? shader)
+ "Return #t if SHADER is a vertex shader, #f otherwise."
+ (eq? (shader-type shader) 'vertex))
+
+(define (fragment-shader? shader)
+ "Return #t if SHADER is a fragment shader, #f otherwise."
+ (eq? (shader-type shader) 'fragment))
+
(define-guardian shader-guardian
(lambda (shader)
(false-if-exception
@@ -183,11 +193,16 @@ shaders or #f otherwise."
(define (display-linking-error shader-program)
(%display-linking-error (shader-program-id shader-program)))
-(define (make-shader-program . shaders)
+(define (make-shader-program vertex-shader fragment-shader)
"Create a new shader program that has been linked with the given
-SHADERS."
+VERTEX-SHADER and FRAGMENT-SHADER."
+ (unless (and (vertex-shader? vertex-shader)
+ (fragment-shader? fragment-shader))
+ (error "Expected a vertex shader and fragment shader"
+ vertex-shader fragment-shader))
(let* ((id (glCreateProgram))
- (shader-program (%make-shader-program id)))
+ (shader-program (%make-shader-program id))
+ (shaders (list vertex-shader fragment-shader)))
(shader-program-guardian shader-program)
(for-each (lambda (shader)
(glAttachShader id (shader-id shader)))