简体   繁体   中英

How does the glVertexAttribPointer stride parameter work?

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?

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 eg 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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM