----- Original Message -----
> 2010/10/18 Vladimir Vukicevic <
vladimir@mozilla.com>:
> > Do you know which version you were using previously?
> >
> I just installed Firefox 4.0b3 and : it works with that.
>
> >Also, what are the arguments to the VertexAttribPointer call?
> shaderProgram.normal = gl.getAttribLocation(shaderProgram, "normal");
> gl.enableVertexAttribArray(shaderProgram.normal);
> ...
>
> gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer);
> gl.vertexAttribPointer(shaderProgram.normal, 3, gl.FLOAT, false, 0,
> 0);
>
>
> just above the bindBuffer i got a binding for positions, which is
> working without problems:
>
> gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer);
> gl.vertexAttribPointer(shaderProgram.position, 3, gl.FLOAT, false, 0,
> 0);
Yep, though I would dump the values of shaderProgram.normal and shaderProgram.position. If the attrib isn't actually in use by the program, then getAttribLocation will return -1. Regardless, this will raise a GL error, but shouldn't have any effect on the rendering.
> > The two problems are likely seperate -- getAttribLocation is
> > returning -1 (that is, saying that the attrib isn't in use by the
> > program), so calling VertexAttribPointer with -1 as a location is
> > invalid. However, this is likely not the cause of your error.
> >
>
> var normalMatrix=mat4.inverse(mvMatrix);
> normalMatrix=mat4.transpose(normalMatrix)
> gl.uniformMatrix4fv(shaderProgram.nMatrixUniform, false,
> normalMatrix); //At this point the UniformMatrix4fv error comes
> along..
Is shaderProgram.nMatrixUniform null?
Yes, it is null, see:
shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "projectionMatrix");
alert(shaderProgram.nMatrixUniform); //OUTPUT: not null
shaderProgram.nMatrixUniform = gl.getUniformLocation(shaderProgram, "normalMatrix");
alert(shaderProgram.nMatrixUniform); //OUTPUT: null
Actually it is similar to the stuff with shaderProgram.pMatrixUniform..
var shaderProgram;
function initShaders() {
var fragmentShader = getShader(gl, "shader-fs");
var vertexShader = getShader(gl, "shader-vs");
shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader);
gl.linkProgram(shaderProgram);
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
alert("Could not initialise shaders");
}
gl.useProgram(shaderProgram);
shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "vertexPosition");
gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);
shaderProgram.vertexNormalAttribute = gl.getAttribLocation(shaderProgram, "vertexNormal");
gl.enableVertexAttribArray(shaderProgram.vertexNormalAttribute);
shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "projectionsMatrix");
shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "modelViewMatrix");
shaderProgram.ambientLight = gl.getUniformLocation(shaderProgram, "ambientLight");
shaderProgram.farbe = gl.getUniformLocation(shaderProgram, "color");
shaderProgram.nMatrixUniform = gl.getUniformLocation(shaderProgram, "normalMatrix");
alert(shaderProgram.pMatrixUniform); //OUTPUT: null
}