注: canvas全屏的时候不要用 canvas.style.width 和canvas.style.height 给100%, 图像会失真;
直接 canvas.width = window.innerWidth; canvas.height = window.innerHeight; 或者
canvas.width = document.documentElement.clientWidth; canvas.height = document.documentElement.clientHeight
来充满全屏;
1. WebGL: INVALID_VALUE: vertexAttribPointer: index out of range 原因:gl.getAttribLocation(shaderProgram, 'aVertexPosition') 变量取不到值,(变量名对不上请仔细对照定义的变量名);
2. 没有报错物体不显示
原因: gl.uniformMatrix4fv 参数有空undefined被传入
3.GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 0
原因: 创建新的buffer时 上一个的buffer没有进行gl.bufferData操作;
4.ERROR :GL_INVALID_ENUM : glTexParameteri: param was GL_CLOSE_PATH_NV
原因:gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINERA); gl.LINEAR写错
5. INVALID_OPERATION: drawElements: no buffer is bound to enabled attribute
原因: gl.enableVertexAttribArray() 参数传了undefined
6.RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
原因: 缺少gl.texImage2D(gl.TEXTURE_2D, level, internalFormat, width, height,border,srcFormat, srcType, pixel);
7. Failed to execute 'attachShader' on 'WebGLRenderingContext': parameter 2 is not of type 'WebGLShader'.
原因: vsSource或者fsSource 格式错误错误