Hi,
I have a VertexArray, a ColorArray and an IndexArray for drawing a surface of triangles.
glColorPointer (3, GL_UNSIGNED_BYTE, sizeof (CGColor3ub), &colorArray[0][0]);
glVertexPointer (3, GL_FLOAT, sizeof (Vertex), &vertexArray[0][0]);
glDrawElements (GL_TRIANGLES, 3*getNumberOfTriangles(), GL_UNSIGNED_INT, triangleIndices);
With the ColorArray I want to color code the whole mesh, so that I can pick one triangle. To be more precise it’s not about picking but about some collision calculation.
Let’s say we have four points A, B, C, D. The first triangle is ABC with the same color for these points in the colorArray, let’s say blue. Now when the second triangle BCD is drawn with the colorPointer pointing to red this triangle is in fact also colored blue.
So here is my question. What should I do to color code the triangle mesh. I guess I could add two points so that the triangles don’t share points. So the better question would be if this colorpointer only sets the color of each vertex once instead of coloring it for each primitive. After writing this it seems to me that I gave myself the answer but I still hope that I am wrong about the colorPointer ;).