This program draws a cube in triangles (ES only draws triangles!) according to defined vertices v0, v1, v2 etc. The vertices are colored by ‘colors array’ and then triangles are drawn via the ‘byte indices’ array. Hope this code and pics are self explanatory ðŸ™‚

source code – you will have to email me for the zip file 3d_3.zip

class Cube

{

public Cube()

{

int one = 0x10000;

int vertices[] = { // vertices draw a cube

-one, -one, -one, //v0

one, -one, -one, // v1

one, one, -one, // v2

-one, one, -one, // v3

-one, -one, one, // v4

one, -one, one, // v5

one, one, one, // v6

-one, one, one, // v7

};

int colors[] = {

0, 0, 0, one, //v0 black – red, green, blue, alpha

one, 0, 0, one, //v1 red

one, one, 0, one, //v2 yellow

0, one, 0, one, //v3 green

0, 0, one, one, // v4 blue

one, 0, one, one, // v5 magenta

one, one, one, one, // v6 white

0, one, one, one, // v7 aqua

};

** byte indices[] = {
0, 4, 5, 0, 5, 1, // Draws v0 then v4 then v5 (triangles) etc
1, 5, 6, 1, 6, 2,
2, 6, 7, 2, 7, 3,
3, 7, 4, 3, 4, 0,
4, 7, 6, 4, 6, 5,
3, 0, 1, 3, 1, 2
};
**