webgl

注: 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 格式錯誤錯誤

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章