Customizations

We are still rendering the cube the same way we left it in Example25. Let's change it to draw every cube face in a different solid color. We can define a different color per vertex, but as vertices are shared between faces, their colors will be interpolated.

We'd have to replicate some vertices so we can have different unique colors for each single face:

 

private float quadCoords[] = { -1.f, -1.f, -1.0f, // 0 -1.f, 1.f, -1.0f, // 1 1.f, 1.f, -1.0f, // 2 1.f, -1.f, -1.0f, // 3 -1.f, -1.f, 1.0f, // 4 -1.f, 1.f, 1.0f, // 5 1.f, 1.f, 1.0f, // 6 1.f, -1.f, 1.0f, // 7 -1.f, -1.f, -1.0f, // 8 - 0 -1.f, -1.f, 1.0f, // 9 - 4 1.f, -1.f, 1.0f, // 10 - 7 1.f, -1.f, -1.0f, // 11 - 3 -1.f, 1.f, -1.0f, // 12 - 1 -1.f, 1.f, 1.0f, // 13 - ...

Get Building Android UIs with Custom Views now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.