How does GL know what my buffer is used for, Pos, UV, Colour or normals???
You allocate a buffer, you fill it and then later bind it. At some point you enable the attribute and you also set up the attribute parameters. There seems to be no point where I tell GL that buffer X is for vertices, texture coords or colours etc…
Maybe I hit my head last night and it fell out, but whilst tracking down a crash bug I’ve got myself all confused…
My best guess that the next call to one of the attribute functions defines what the last bound buffer is for, if so which?
Ta.
When you call glVertexAttribPointer, the buffer that is bound to GL_ARRAY_BUFFER is bound to that attribute slot. Binding a buffer to GL_ARRAY_BUFFER by itself does not affect any attributes, it has to be followed by calls to glVertexAttribPointer.
The actual meaning (position, texture coords, colours, etc.) of a vertex attribute is determined solely by how it is used in the vertex shader.
Ah good, that is what after some more thinking I was hoping was going on. Was getting a little confused by the DX SetStreamSource and thinking it was similar to glBindBuffer.
I’ve got this right, glBindBuffer just says “this is the buffer that all other related operations will use / operate on”.
Thanks.