Open randfur opened 1 year ago
This issue can be closed.
It is not an issue with the docs, it's a misunderstanding of how to use vertexAttribPointer()
vs vertexAttribIPointer()
(I for Integer).
I answered this (again) on Stack Overflow the other day.
In short the type
in vertexAttribPointer()
is not the data type in the shader. It's the data type of the data stored in the vertex buffer. In other words, vertexAttribPointer()
tells that the shader is receiving floats. However, the actual data in the vertex buffer can be floats, unsigned integers, bytes, etc. But in the end they are converted (normalized or not) into floats.
Whereas, if you want to receive integers in the shader. Then you need to use vertexAttribIPointer()
(I for Integer). Again the data type
is the data type in the vertex buffer.
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer
What specific section or headline is this issue about?
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer#parameters
What information was incorrect, unhelpful, or incomplete?
I tried using
gl.UNSIGNED_INT
but kept gettingWebGL warning: drawArraysInstanced: Vertex attrib 0 requires data of type UINT, but is being supplied with type FLOAT.
errors.What did you expect to see?
Turns out I have to use https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/vertexAttribIPointer instead for integer types.
Do you have any supporting links, references, or citations?
https://stackoverflow.com/a/17261259/866521
Do you have anything more you want to share?
No response
MDN metadata
Page report details
* Folder: `en-us/web/api/webglrenderingcontext/vertexattribpointer` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/webglrenderingcontext/vertexattribpointer/index.md * Last commit: https://github.com/mdn/content/commit/eda49877b9078b24cd18f794470e5e225add9b94 * Document last modified: 2023-04-08T06:46:30.000Z