Webgl is turning out to be a real horror show. How do humans work with this? Ahh.. :P
Anyway, I am trying to start simple and create a 4-vertex quad to display on screen at the bottom of the drawgl() function. I've managed to create a buffer for the vertices in InitState and bind it to the arraybuffer. So far so good I guess. When I try to draw the thing though, I get an error message about the shaderProgram not being defined. This shaderprogram seems to be specific to C2 so I can't dig up any solution on the internet. How do I define this? The DrawGL() snippet looks like this:
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer);
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0);
// mat4.translate(matmv, [3.0, 0.0, 0.0]);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems);
EDIT: Ah, nevermind. Figured it out.
EDIT2: Right, this is what I have in DrawGL right now. It runs fine but I see no quad.
var shaderProgram = gl.createProgram();
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer);
mat4.translate(gl.matMV, [3.0, 0.0, 0.0]);
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.uniformMatrix4fv(shaderProgram.locMatP, false, gl.matP);
gl.uniformMatrix4fv(shaderProgram.locMatMV, false, gl.matMV);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems);
edited><editID>ErekT</editID><editDate>2013-10-13 18:55:14</editDate></edited>