I have this, wich will read in vec2, is it possible to forward just one, so the vertex shader will recieve in each 0,1 then 1,2 2,3 and so on?
float v[]{0,1,2,3,4...};
glVertexAttribPointer((GLuint)0, 2, GL_FLOAT, GL_FALSE, 0, 0);
This feels like a hack, but you could explicitely set the stride
parameter of glVertexAttribPointer
to the size of a single float
.
Basically, whenever the GL fetches a vertex with index i
, it will use the address offset + i * stride
. The 0
you are using currently as stride parameter is a convenience shortcut meaning a tightly packed array, so it will be equivalent to 2 * sizeof(GLfloat)
in your case, but there is nothing in the GL which prevents you from setting a stride below that value of a tightly packed array:
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat), 0);