Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid index buffer type #47

Open
vorg opened this issue Aug 12, 2018 · 3 comments
Open

Invalid index buffer type #47

vorg opened this issue Aug 12, 2018 · 3 comments
Labels
type/fix A bug fix

Comments

@vorg
Copy link
Member

vorg commented Aug 12, 2018

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
Copy link
Member Author

vorg commented Aug 20, 2018

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
Copy link
Member Author

vorg commented Sep 11, 2018

Error: Unknown buffer type: 5125

@vorg vorg closed this as completed in e8281c7 Sep 14, 2018
@vorg vorg reopened this Sep 14, 2018
@vorg
Copy link
Member Author

vorg commented Sep 14, 2018

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

@dmnsgn dmnsgn added type/fix A bug fix and removed bug labels Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix A bug fix
Projects
None yet
Development

No branches or pull requests

2 participants