GLfloat vertices[] = {
-1., -1., -1., // NODE 0
1., -1., -1., // NODE 1
1., 1., -1., // NODE 2
-1., 1., -1., // NODE 3
-1., -1., 1., // NODE 4
1., -1., 1., // NODE 5
1., 1., 1., // NODE 6
-1., 1., 1. }; // NODE 7
GLubyte frontIndices[] = { 4,5,6,7 }; // FACE 1 : NODES 4, 5, 6, 7
GLubyte rightIndices[] = { 1,2,6,5 }; // FACE 2
GLubyte bottomIndices[] = { 0,1,5,4 }; // FACE 3
GLubyte backIndices[] = { 0,3,2,1 }; // FACE 4
GLubyte leftIndices[] = { 0,4,7,3 }; // FACE 5
GLubyte topIndices[] = { 2,3,7,6 }; // FACE 6
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-2., 2., -2., 2., 1., 100.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(15., 10., 10., 0., 0., 0., 0., 0., 1.);
glEnable(GL_DEPTH_TEST);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glColor3f(1.0, 0.0, 0.0); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, frontIndices);
glColor3f(1.0, 1.0, 0.0); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, backIndices);
glColor3f(0.0, 1.0, 0.0); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, leftIndices);
glColor3f(0.0, 1.0, 1.0); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, rightIndices);
glColor3f(1.0, 0.0, 1.0); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, topIndices);
glColor3f(1.0, 1.0, 1.0); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, bottomIndices);