what works:
shader
#version 330 core
attribute vec3 pos;
attribute vec2 uv;
out vec3 color;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * vec4(pos.xy, sin(10.0*(pos.x + pos.y))/8.0 + 1.0, 1.0);
color = vec3(pos.xy, sin(10.0*(pos.x + pos.y))/8.0);
}
python
vao = glGenVertexArrays(1)
glBindVertexArray(vao)
# [x, y, z]
vertices = vbo.VBO(np.array([[...],[...],...], dtype=np.float32))
def draw():
glUseProgram(program)
glUniformMatrix4fv(projectionLoc, 1, False, perspectiveMatrix)
glUniformMatrix4fv(viewLoc, 1, False, viewMatrix)
vertices.bind()
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointer(3, GL_FLOAT, 12, vertices)
glDrawArrays(GL_TRIANGLES, 0, lenVerticesArray)
vertices.unbind()
I would like to either, have a separate array of uv values [x, y] to pass through to the uv attribute, or to append them to the current vertices as [x, y, z, ux, uy] and have those be the uv attribute.
I tried doing the following with the combined [x, y, z, ux, uy]:
glEnableVertexAttribArray(posLoc)
glVertexAttribPointer(posLoc, 3, GL_FLOAT, False, 12, vertices)
glEnableVertexAttribArray(uvLoc)
glVertexAttribPointer(uvLoc, 2, GL_FLOAT, False, 12, vertices+12)
However, this does not work. Everything else I have tried is some variation of this, all of which fails. I cannot seem to understand what to properly do to send the data.