Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在共享顶点上应用颜色_C++_Opengl - Fatal编程技术网

C++ 在共享顶点上应用颜色

C++ 在共享顶点上应用颜色,c++,opengl,C++,Opengl,我当前不希望的输出: 在这种实现中,有可能在单个四边形上应用单一颜色吗?常见的误解是“顶点”表示“位置”。顶点是其属性的整体组合,其中包括位置、颜色、纹理坐标等。如果两个顶点之间的属性之一不同,则顶点不相同 如果要为两个四边形指定不同的纯色,则它们不共享顶点 我认为剩下的应该是显而易见的。人们普遍误解“顶点”是“位置”的意思。顶点是其属性的整体组合,其中包括位置、颜色、纹理坐标等。如果两个顶点之间的属性之一不同,则顶点不相同 如果要为两个四边形指定不同的纯色,则它们不共享顶点 我认为其余的应该

我当前不希望的输出:


在这种实现中,有可能在单个四边形上应用单一颜色吗?

常见的误解是“顶点”表示“位置”。顶点是其属性的整体组合,其中包括位置、颜色、纹理坐标等。如果两个顶点之间的属性之一不同,则顶点不相同

如果要为两个四边形指定不同的纯色,则它们不共享顶点


我认为剩下的应该是显而易见的。

人们普遍误解“顶点”是“位置”的意思。顶点是其属性的整体组合,其中包括位置、颜色、纹理坐标等。如果两个顶点之间的属性之一不同,则顶点不相同

如果要为两个四边形指定不同的纯色,则它们不共享顶点


我认为其余的应该是显而易见的。

那么我应该重复顶点吗?@mr5不重复,因为它们显然不一样。@user1095108我的意思是,添加比我当前的顶点更多的顶点?那么我应该重复顶点吗?@mr5不重复,因为它们显然不一样。@user1095108我的意思是,添加比我当前的顶点更多的顶点?
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,
};