无法获取第 4 个向量以在 WebGL 中呈现 TRIANGLE_STRIP
Cannot get 4th vector to render in WebGL TRIANGLE_STRIP
我正在尝试使用 WebGL,我可以在 this plunker 中渲染一个三角形。现在我尝试通过更改...
使它成为一个完整的正方形
//This...
this.triangleVertexPositionBuffer.numItems = 3;
// ...
this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, this.triangleVertexPositionBuffer.numItems);
// To this..
this.triangleVertexPositionBuffer.numItems = 4;
这对我来说应该只是一个正方形,然而,三角形完全消失了。我还收到以下警告...
GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 1
我在这里错过了什么?
您还需要为第四个顶点添加颜色属性。
我正在尝试使用 WebGL,我可以在 this plunker 中渲染一个三角形。现在我尝试通过更改...
使它成为一个完整的正方形//This...
this.triangleVertexPositionBuffer.numItems = 3;
// ...
this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, this.triangleVertexPositionBuffer.numItems);
// To this..
this.triangleVertexPositionBuffer.numItems = 4;
这对我来说应该只是一个正方形,然而,三角形完全消失了。我还收到以下警告...
GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 1
我在这里错过了什么?
您还需要为第四个顶点添加颜色属性。