【发布时间】:2015-07-04 07:12:52
【问题描述】:
我对 OpenGL 比较陌生,并尝试学习一点 WebGl。我遇到了a tutorial,虽然很棒,但似乎有点过时了。我实现了我自己的example in a Plunkr 版本。我故意省略了正方形,然而,一旦我把所有东西都连接好,我就看不到三角形了。我在控制台中发现了一个警告...
WARNING: Attribute 0 is disabled. This has signficant performance penalty
还有另一个SO question 似乎很相似,但通过差异查看我无法让它工作,我无法得到他所说的点击。这是我的绘图代码供参考...
drawScene() {
this.gl.viewport(0, 0, this.gl.viewportWidth, this.gl.viewportHeight);
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
mat4.perspective(45, this.gl.viewportWidth / this.gl.viewportHeight, 0.1, 100.0, this.pMatrix);
mat4.identity(this.mvMatrix);
mat4.translate(this.mvMatrix, this.mvMatrix, [-1.5, 0.0, -7.0]);
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.triangleVertexPositionBuffer);
this.gl.vertexAttribPointer(this.shaderProgram.vertexPositionAttribute, this.triangleVertexPositionBuffer.itemSize, this.gl.FLOAT, false, 0, 0);
this.setMatrixUniforms();
this.gl.drawArrays(this.gl.TRIANGLES, 0, this.triangleVertexPositionBuffer.numItems);
}
有没有人有经验可以帮助指导新手?
【问题讨论】:
标签: webgl