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

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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