This may not be possible directly: glutSolidCube
does not generate color attributes (see the fghCube
function in freeglut source code).
The simplest way would be to generate the geometry of the cube yourself. Generate 6 (faces) * 4 = 24 vertices total, with the expected positions, normals and an additional color attribute per vertex. Just like for the normal attribute, for each of the 8 distinct vertex positions on a cube, you should have 3 different colors (since the same vertex is shared by 3 faces but you need a different color per face).
Another way if you really insist on using glutSolidCube
would be to assign the vertex color based on the vertex normal in the vertex shader. But maybe you are not using vertex shaders...