Dart: web_gl: getAttributeLocation returns -1

A call getAttributeLocation(program,"aTextureCoords")in my code returns -1

However:

  • The attribute is active (i.e. the question getAttribLocation Webgl is not duplicated, strange returns -1 )

  • Correctly written

  • It has no invalid characters

  • It does not start with a reserved prefix.

  • It is shorter than 255 characters

  • Missed program is not invalid

What could be wrong?

My (built-in) 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 matters, but I will post it if necessary.


EDIT:

glGetAttribLocation returns -1 when retrieving an existing shader attribute . Location binding is supposed to be better than getting location. I will try this.

EDIT2: , , .

+3

All Articles