4
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ See What is glVertexAttrib (vs. glVertexAttribPointer) used for?. Essentially, they're the same thing, but glVertexAttrib is for the older immediate mode. $\endgroup$ Commented Oct 21, 2017 at 5:17
  • $\begingroup$ 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. $\endgroup$ Commented Oct 22, 2017 at 20:21

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.