int x = 100;
int y = 100;
int width = 250;
int height = 250;
int border = 10;
int top = y + border;
int bottom = y + height;
int left = x + border;
int right = x + width;
static int vertices[] = {
x, y, //0
right, y, //1
right, bottom, //2
x, bottom, //3
left, top, //4
right - border, top, //5
right - border, bottom - border, //6
left, bottom - border, //7
left, top + (height - border - border) * 0.5,
right - border, top + (height - border - border) * 0.5
};
static unsigned int indices[] = {
0, 1, 4, 5, //top border
5, 1, 6, 2, //right border
2, 6, 3, 7, //bottom border
7, 4, 3, 0, //left border
4, 5, 8, 9,
8, 9, 7, 6,
};
static unsigned char colors[] = {
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0xff, 0x00, 0x00,
0xff, 0x00, 0x00,
0xff, 0x00, 0x00,
0xff, 0x00, 0x00,
0x00, 0xff, 0x00,
0x00, 0xff, 0x00,
0x00, 0xff, 0x00,
0x00, 0xff, 0x00,
0x00, 0x00, 0xff,
0x00, 0x00, 0xff,
0x00, 0x00, 0xff,
0x00, 0x00, 0xff,
};
我当前不需要的输出:
在这种实现中是否可以在单个四边形上应用单一颜色?
最佳答案
“顶点”的意思是“位置”,这是一种常见的误解。一个顶点是其属性的整体组合,其中包括位置、颜色、纹理坐标等。如果两个顶点之间的属性之一不同,则顶点不相同。
如果您想为两个四边形赋予不同的纯色,则它们不共享顶点。
我认为其余的应该是显而易见的。
关于c++ - 在共享顶点上应用颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17576596/