# Thread: Applying colors on shared vertices

1. ## Applying colors on shared vertices

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,

};

My current undesired output:

<error>

Is it possible to apply a single color on a single quad in this kind of implementation?

2. Strictly each vertex has only has one set of data including colour; you can repeat a vertex position and have a different colour for each repetition.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•