Javascript WebGL不绘制简单的三角形
我检查了gl.getError(),但它返回了0。帮帮忙,这可能是非常简单的事情,这使得它最难挑出Javascript WebGL不绘制简单的三角形,javascript,google-chrome,graphics,3d,webgl,Javascript,Google Chrome,Graphics,3d,Webgl,我检查了gl.getError(),但它返回了0。帮帮忙,这可能是非常简单的事情,这使得它最难挑出 我在绘图后立即检查了gl.getError,但仍然没有错误。我还检查了其他一切,看它是否到位,似乎都很好。不知道是什么原因造成的您发送了两次uVMatrix uniform: this.setMatrixUniforms = function() { gl.uniformMatrix4fv(this.uMUniform, false, this.pipeline.mMatrix)
我在绘图后立即检查了gl.getError,但仍然没有错误。我还检查了其他一切,看它是否到位,似乎都很好。不知道是什么原因造成的您发送了两次uVMatrix uniform:
this.setMatrixUniforms = function() {
gl.uniformMatrix4fv(this.uMUniform, false, this.pipeline.mMatrix);
gl.uniformMatrix4fv(this.uVUniform, false, this.pipeline.vMatrix);
gl.uniformMatrix4fv(this.uVUniform, false, this.pipeline.vMatrix);
}
你想要的是:
this.setMatrixUniforms = function() {
gl.uniformMatrix4fv(this.uMUniform, false, this.pipeline.mMatrix);
gl.uniformMatrix4fv(this.uVUniform, false, this.pipeline.vMatrix);
gl.uniformMatrix4fv(this.uPUniform, false, this.pipeline.pMatrix);
}
您还需要将其他矩阵初始化为标识:
function Pipeline() {
this.mMatrix = mat4.identity();
this.vMatrix = mat4.identity();
this.pMatrix = mat4.create();
}
为了使mat4.identity()升级,我将glMatrix库升级到了一个更新的版本:
<script src = "gl-matrix-1.3.7.js"></script>
在此处查找完整更改:
<script src = "gl-matrix-1.3.7.js"></script>