I'm having trouble mapping UV coordinates to vertices in OpenGL. I'm binding my buffers and enabling all of my attrib arrays perfectly well and things are rendering - but what I'm stuck on is how to map UV and Normal data.
You can't just store UV and Normal data with the Vertex data, because obviously you'll be re-using vertices, but not necessarily with the same Normal or UV.
For clarity this is the general flow of what I'm doing at the moment:
- I bind my shader program.
- I bind my vertex array buffer with GL.BindBuffer
- I Bind my element buffer with GL.BindBuffer
- I use GL.Uniform (1, 2, 3 or 4) to bind values to my uniform variables
- I enable all of my vertex buffer attributes with GL.EnableVertexAttribArrau and then encode their layout using GL.VertexAttribPointer
- I draw using GL.DrawElements
- I disable all of my vertex attrib arrays again
I'm totally stuck on how to encode UV and Normal data to my vertex attributes. Do I need to use a second buffer? If so; how does OpenGL know to use a different set of indices to find them? I'm totally lost and any help would be greatly appreciated.