setAttribute()
ts
function setAttribute(
gl: WebGL2RenderingContext,
program: WebGLProgram,
name: string,
attribute: Attribute,
): {
location: number;
vertexCount: number;
};Sets up a vertex attribute for a given shader program.
This function handles buffer creation, binding, and attribute pointer configuration. It also supports special handling for the "index" attribute (ELEMENT_ARRAY_BUFFER).
Parameters
gl
WebGL2RenderingContext
The WebGL2 context.
program
WebGLProgram
The WebGL program containing the attribute.
name
string
The name of the attribute in the shader.
attribute
The attribute data and configuration.
Returns
| Name | Type | Description |
|---|---|---|
location | number | The location of the attribute in the shader program. |
vertexCount | number | The computed vertex count based on the attribute data and configuration. |