WebGL drawing failure after mouse click
问题 I have a helper method drawRect(p1, p2) that draws a rectangle (in orthographic projection). The code works fine if I do this: function webGLStart() { // initialization code gl.clear(gl.COLOR_BUFFER_BIT); gl.uniformMatrix4fv(shaderProgram.pMatrixLoc, false, pMatrix); drawRect(new Point(10, 10), new Point(50, 50)); } Now suppose I want to render a new rectangle after every mouse click. So I cleared the canvas, set up the projection matrix and moved the drawRect call in mouse down handler. And