From 47bd87f7cdeca80e822ce0a671451ecb78e69343 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 25 Oct 2014 09:51:48 -0400 Subject: shader: Explicitly bind attribute locations before binding. * sly/shader.scm (vertex-position-location, vertex-texture-location): New variables. (make-shader-program): Bind attribute locations. --- sly/shader.scm | 8 ++++++++ 1 file changed, 8 insertions(+) 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 (($ 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") -- cgit v1.2.3