pex-context icon indicating copy to clipboard operation
pex-context copied to clipboard

Invalid index buffer type

Open vorg opened this issue 6 years ago • 3 comments

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)

vorg avatar Aug 12 '18 15:08 vorg

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 }

vorg avatar Aug 20 '18 09:08 vorg

Error: Unknown buffer type: 5125

vorg avatar Sep 11 '18 13:09 vorg

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

vorg avatar Sep 14 '18 10:09 vorg