I have one vbo where I would like to use each attribute for two drawn vertices instead of just one, in forward mode, you could simply do it like this:
glVertexAttrib4f(loc, bpos.x, bpos.y, bpos.z, 0.5);
glVertex3f(-1, -1, -1);
glVertex3f(1, 1, 1);
to make sure the attribute gets used for the next two vertices. I don’t see any way of doing this with VBOs unless I put each attribute twice into the attribute array. Is there any way to use each element in an attribute array twice?
Is there any way to use each element in an attribute array twice?
Not without duplicating it. Or a lot of effort (which involves writing shaders to access the buffer object contents directly).
okay, I was just wondering if I was missing something! thanks!
Possibly you can do it by drawing 2-vertex geometry (line segment) with instancing (number of instances equal to number of your vertex pairs). Use glVertexAttribDivisor to specify vertex attribute buffer position to be advanced once per instance. In geometry shader construct primitives you need manually. Never done something like before, but see no reasons why it won’t work.
Alternatively, you may feed vertex shader with point primitives and specify divisor=2.
glVertexAttribDivisor is available since opengl 3.2