summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-10-25 09:51:48 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-10-25 09:51:48 -0400
commit47bd87f7cdeca80e822ce0a671451ecb78e69343 (patch)
treece043e4e31584d7af6fe72543ef5e29127bfdc36
parentad59dab0d1494f8c0372bc65b3849a69032ee5bc (diff)
shader: Explicitly bind attribute locations before binding.
* sly/shader.scm (vertex-position-location, vertex-texture-location): New variables. (make-shader-program): Bind attribute locations.
-rw-r--r--sly/shader.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/sly/shader.scm b/sly/shader.scm
index 2973010..4c31edc 100644
--- a/sly/shader.scm
+++ b/sly/shader.scm
@@ -45,6 +45,8 @@
shader-id
make-shader-program
load-shader-program
+ vertex-position-location
+ vertex-texture-location
shader-program-uniform-location
shader-program-attribute-location
shader-program-id
@@ -196,6 +198,9 @@ in the file FILENAME."
(uniforms shader-program-uniforms)
(attributes shader-program-attributes))
+(define vertex-position-location 0)
+(define vertex-texture-location 1)
+
(define (shader-program-uniform-location shader-program uniform-name)
(let ((uniform (find (match-lambda
(($ <uniform> name _)
@@ -248,6 +253,9 @@ VERTEX-SHADER and FRAGMENT-SHADER."
(for-each (lambda (shader)
(glAttachShader id (shader-id shader)))
shaders)
+ ;; Bind attribute locations
+ (glBindAttribLocation id vertex-position-location "position")
+ (glBindAttribLocation id vertex-texture-location "tex")
(glLinkProgram id)
(unless (shader-program-linked? id)
(display "Failed to link shader program:\n")