Take this example, where a cube light has hardcoded vertices and indices:
GLfloat lightVertices[] =
{ // Coordinates
-0.001f, -0.001f, 0.001f,
-0.001f, -0.001f, -0.001f,
0.001f, -0.001f, -0.001f,
0.001f, -0.001f, 0.001f,
-0.001f, 0.001f, 0.001f,
-0.001f, 0.001f, -0.001f,
0.001f, 0.001f, -0.001f,
0.001f, 0.001f, 0.001f
};
GLuint lightIndices[] =
{
0, 1, 2,
0, 2, 3,
0, 4, 7,
0, 7, 3,
3, 7, 6,
3, 6, 2,
2, 6, 5,
2, 5, 1,
1, 5, 4,
1, 4, 0,
4, 5, 6,
4, 6, 7
};
What if I wanted to create a larger cube light, or a light of a different shape – is there a standard way that graphics programmers automate the creation of indices from coordinates? If your object has a million coordinates, it is not practical to create an index array manually, so how do graphics programmers do this in practice?
I have researched this question with things such as “how to automate creation of index buffer data based upon vertex array data” with no avail.
Jacob Elliott is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.