我们不允许绑定 gl 吗?ARRAY_BUFFER和顶点属性数组在WebGL(2)中为0



在openGL中 通常通过调用(相当于以下OGL(来"解除绑定"您的ARRAY_BUFFER和任何绑定的VAO:

gl.bindBuffer(gl.ARRAY_BUFFER, 0)
gl.bindVertexArray(0)

但是,当我在WebGL(2(中执行此操作时,我收到以下错误:

Uncaught TypeError: Failed to execute 'bindBuffer' on 'WebGL2RenderingContext': parameter 2 is not of type 'WebGLBuffer'.

我们不应该在WebGL(2(中这样做吗?

你必须传入null而不是 0

gl.bindBuffer(gl.ARRAY_BUFFER, null)
gl.bindVertexArray(null)

由于各种原因,WebGL不像OpenGL那样使用GLint id,它使用对象WebGLBufferWebGLTextureWebGLVertexArrayObject等...0版本是null

最新更新