I'm wondering if it's possible in OpenGL (via extensions or otherwise) to have an attribute array specified by the glVertexAttribPointertype functions that advances by one for every primitive (or N vertices) instead of one for every vertex?
For example, if I have an array of triangles which have a solid color currently I'm having to repeat the same color data for every vertex, what I would like instead is something along these lines:
struct pos {
uint8_t x, y;
} positions[NUM_VERTICES];
struct col {
uint8_t r, g, b;
} colors[NUM_VERTICES / 3];
Where one element of the colors array is reused for every 3 consecutive positions elements when both arrays are submitted to OpenGL with glVertexAttribPointer and renderered with a single glDrawArrays(GL_TRIANGLES, ...);
I found the ARB_instanced_arrays extension, which provides the glVertexAttribDivisorARB function which seemed promising at first, but I don't think it works the way I've described.
This is essentially an alternate form of this question about multi-indexed rendering (it's different, which is why I'm not calling it a duplicate). The simple answer is no. The less simple answer is to do the accessing and indexing yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With