O'Reilly logo

Building Android UIs with Custom Views by Raimon Ràfols Montané

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 - ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required