A call to getAttributeLocation(program,"aTextureCoords")
in my code returns -1
However:
The attribute is active (ie not a duplicate question to Webgl's getAttribLocation oddly returns -1)
It is spelt correctly
It has no invalid characters
It doesn't start with a reserved prefix
It is shorter than 255 chars
The passed program isn't invalidated
What could be wrong?
My (embedded) shader code:
<script type="x-shader/x-vertex" id="vertex">
attribute vec3 aVertexPosition;
attribute vec2 aTextureCoords;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
varying highp vec2 vTextureCoords;
void main() {
gl_Position = uPMatrix*uMVMatrix*vec4(aVertexPosition,1.0);
vTextureCoords = aTextureCoords;
}
</script>
<script type="x-shader/x-fragment" id="fragment">
varying highp vec2 vTextureCoords;
uniform sampler2D uSampler;
void main() {
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
texture2D(uSampler,vec2(vTextureCoords.s,vTextureCoords.t));
}
</script>
I don't think the rest of my code is relevant, but I will post it if needed.
EDIT:
glGetAttribLocation returns -1 when retrieving existing shader attribute Suggests that binding a location is better than getting a location. I'll try this.
EDIT2: This has fixed my problem, but I would still like to know what caused it in the first place.