I have no idea why would you want to draw each n-th triangle, and I cannot imagine a situation in which you would want to do that.
...but supposing you do have a legitimate reason to do that...
I would say you can't, because glVertexAttribPointer
is used to set the layout for the data at the vertex level, not the triangle level. In fact, OpenGL has no idea of how are you going to use the vertices inside the vertex buffer until you make a draw call.
I suppose you were thinking about playing with the stride
parameter, but once again, glVertexAttribPointer
works at the vertex level, so the most you can do is make triangles out of each n-th vertex, which is not what you want.
Short of creating a new vertex buffer, you can handle this when making the draw call. glDrawArrays
takes the amount of triangles you want to draw and the offset from which you want to draw them, so you would have to do something like
for (int k = 0; k < totalTriangleCount; k += n)
glDrawArrays(GL_TRIANGLES, k * 3, 3);
You might be tempted to think that this is a performance killer, but it's most likely not. You will most likely not be issuing an OpenGL flush on each glDrawArrays
call, so I wouldn't say performance would drop noticeably. At least compared with creating and uploading a new vertex buffer each frame.
Now, the real question is "why would you want to do such a thing?", but we may never know...