# Role of gl.vertexAttrib

I'm re-learning WebGL, and I stumbled upon gl.vertexAttribPointer and gl.vertexAttrib. To my knowledge, gl.vertexAttribPointer tells the GPU how the data in the currently binded buffer relates to the vertex attributes. But, I'm confused on what gl.vertexAttrib does. It seems like it also sends data to the GPU, but without the use of a buffer. Can anybody explain it's role to me?

• See What is glVertexAttrib (vs. glVertexAttribPointer) used for?. Essentially, they're the same thing, but glVertexAttrib is for the older immediate mode. – user1118321 Oct 21 '17 at 5:17
• Thanks for the response! I think I understand the difference now. One sets a constant value, and the other links the values to a buffer. – Daniel Kareh Oct 22 '17 at 20:21

## 1 Answer

gl.vertexAttribPointer is used when different vertices should have different values, and gl.vertexAttrib is used when all vertices should have the same values, and you don't want to use a special shader with a uniform.