glBindVertexBuffer and non-interleaved buffers

I just want to be sure I’m not missing something here, but…

Let’s say I have a single buffer. It has non-interleaved data, consisting of tightly packed position data, followed by tightly packed UV’s.

I’m currently using glVertexAttribPointer with stride set to zero and an offset to where each set of attributes lives, and all of that works just fine.

I’m now moving towards a DSA approach, and it seems that glVertexAttribFormat doesn’t really allow me to do this with only a single attribute binding. Is that correct?

Is the only way to do this to create seperate bindings for each attribute?

That’s not difficult at all (and of course, I could just use interleaved attributes) - I just want to confirm my understanding.

Multiple attributes sourcing from the same binding is how you do interleaved attributes in the API. If you don’t have interleaved attributes, then you’re going to have to use multiple, separate bindings.

1 Like

glVertexAttribPointer is basically equivalent to glBindVertexBuffer, glVertexAttribBinding and glVertexAttribFormat. If all attributes are sourced from the same buffer and use the same stride, you only need to call glVertexAttribFormat for each attribute. If they have different strides, you need to call glBindVertexBuffer for each attribute.

Incorrect. They would also need to use the same offset, which in the OP’s case, they do not: “an offset to where each set of attributes lives”. And no, relativeoffset in glVertexAttribFormat isn’t going to work, as it has a relatively small size limit.

I see. That’s not required to be more than 2047, so I guess it’s only useful for an offset within a vertex structure.

Perfect, that confirms my understanding. Thank you both, @GClements + @Alfonse_Reinheart

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.