pex-context
pex-context copied to clipboard
Invalid index buffer type
When using pex-renderer with uint32 the indices type was uint16 while cmd.indices.buffer.type was uint32 which causes glitches in rendering. https://github.com/pex-gl/pex-context/blob/master/index.js#L761
var type = cmd.indices.type || indexBuffer.type
Test code. Is it because we are updating geometry?
ctx.gl.getExtension('OES_element_index_uint')
newGeo.cells = { buffer: ctx.indexBuffer(new Uint32Array(newGeo.cellsFlat)) }
pointCube.getComponent('Geometry').set(newGeo)
Why do we support cmd.indices.type at all? Is this for gltf where shared subbuffer has to be reinterpreted as index data?
The problematic code in pex-renderer is here https://github.com/pex-gl/pex-renderer/blob/master/geometry.js#L123
As just using typed array keeps old Uint16 type still set.]
g.cells = new Uint32Array(flatten(g.cells))
This can can be solved by
g.cells = { data: new Uint32Array(flatten(g.cells)), type: graph.ctx.DataType.Uint32 }
Error: Unknown buffer type: 5125
So this is more tricky because in pex-context
buffers have type while in webgl they dont
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData
Index element arrays and attrib buffers do https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements
That's why i duplicate type in both buffer and attribute.
attrib.type || buffer.type || gl.FLOAT