Using 4 vertices per face is the correct way to do this. Why do you think that there will be a relevant "performance hit"? Texturing would very likely introduce a much larger performance loss.
Assign color to each side of a cube OpenFrameworks
-
16-06-2023 - |
Pregunta
I'm looking for a way to draw a cube with a unique color per side. Currently, I'm using the following for the vertex and index data with w = width, h = height, and d = depth:
GLfloat vdata[8][3] = {
{-w, -h, -d}, {-w, h, -d},
{w, h, -d}, {w, -h, -d},
{-w, -h, d}, {w, -h, d},
{-w, h, d}, {w, h, d}
};
GLint indices[6][4] = {
{3, 2, 1, 0},
{3, 5, 4, 0},
{3, 5, 7, 2},
{0, 4, 6, 1},
{1, 2, 7, 6},
{5, 4, 6, 7}
};
I'm somewhat certain that I could just draw four vertices per face to achieve what I'm after, but I'd rather not take the performance hit of drawing all those extra vertices. Would a mapped texture make more sense?
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow