Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the glVertexAttribPointer stride parameter work?

Tags:

c++

c

opengl

glew

How does the stride parameter of the glVertexAttribPointer function work? Lets say I have a buffer which is 64 bytes large. I want to store 2 vertices which are 32 bytes large each. If the vertices start one after another, does the stride parameter need to be 0 or 32? What I'm trying to say is does the stride parameter count from the start of the last vertex or from the end of the last vertex?

like image 899
Serket Avatar asked Jul 07 '26 10:07

Serket


1 Answers

It counts from the start of the previous vertex.

But stride == 0 is a special case, it means that your attributes are tightly packed. So e.g. if you're passing a dvec4 (vector of 4 doubles) per vertex, it doesn't matter if you use 0 or 32 (if sizeof(double) * 4 == 32).

like image 192
HolyBlackCat Avatar answered Jul 09 '26 02:07

HolyBlackCat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!