3

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.

Community
  • 1
  • 1
lightandlight
  • 1,345
  • 3
  • 10
  • 24
  • 1
    ideas, you mis-spelled it (yea, I know you said you checked), you're querying a different program, you're using a different shader. [Here's a jsfiddle](http://jsfiddle.net/greggman/vZ42a/). Does it also return -1? – gman Feb 23 '14 at 05:35
  • @gman It does. What does this mean? – lightandlight Feb 23 '14 at 06:19
  • Sounds like there's a bug in your driver. What's your OS/GPU? `about:gpu` should give you details. You should consider filing a bug at http://crbug.com, also check firefox and see you get the same result. – gman Feb 23 '14 at 08:59
  • It happens on both firefox and chrome. I'm running up-to-date archlinux x86_64, Mesa 10.0.3, Intel Ivybridge Mobile – lightandlight Feb 23 '14 at 10:05

0 Answers0