为立方体的每一面分配颜色

Assign color to each side of a cube OpenFrameworks

本文关键字:分配 颜色 立方体      更新时间:2023-10-16

我正在寻找一种方法来绘制一个立方体与独特的颜色每边。目前,我使用以下w = width, h = height和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}
};

我有点确定,我可以每面画四个顶点来实现我所追求的,但我宁愿不采取绘制所有这些额外顶点的性能打击。贴图纹理会更有意义吗?

每个面使用4个顶点是正确的方法。为什么你认为会有一个相关的"性能打击"?纹理化很可能会导致更大的性能损失。