Code:

#include <GLUT/glut.h> /* includes gl.h and glu.h for Mac OS X */
#include <math.h>
int edgeLen = 1;
GLfloat x1[13] = {-0.5, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0};
GLfloat x2[13] = {0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0};
GLfloat yy[13] = {-0.5, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0};
GLfloat y2[13] = {0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0};
GLfloat z1[13] = {0.5, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0};
GLfloat z2[13] = {0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0};
double eyex = 5.0;
double eyez = 5.0;
double tempx = 0.0;
double tempz = 0.0;
double theta = 0.1;
/*
Calculates points of the cube given the bottom left
point on the front face of the cube and the length of
the sides. Stores points in arrays for future use.
*/
void init_mod()
{
int sidesDrawn = 0;
int axis1 = 0;
int axis2 = 1;
int loc = 1;
int m, n, q, r;
for(n = 0; n < 3; n++)
{
for(m = 0; m < 2; m++)
{
switch (axis1) {
case 0:
x1[loc] = x1[0] + edgeLen;
yy[loc] = yy[0];
z1[loc] = z1[0];
break;
case 1:
x1[loc] = x1[0];
yy[loc] = yy[0] + edgeLen;
z1[loc] = z1[0];
break;
case 2:
x1[loc] = x1[0];
yy[loc] = yy[0];
z1[loc] = z1[0] - edgeLen;
break;
}
loc++;
switch (axis2) {
case 0:
x1[loc] = x1[loc - 1] + edgeLen;
yy[loc] = yy[loc - 1];
z1[loc] = z1[loc - 1];
break;
case 1:
x1[loc] = x1[loc - 1];
yy[loc] = yy[loc - 1] + edgeLen;
z1[loc] = z1[loc - 1];
break;
case 2:
x1[loc] = x1[loc - 1];
yy[loc] = yy[loc - 1];
z1[loc] = z1[loc - 1] - edgeLen;
break;
}
loc++;
axis2 = axis1;
axis1 = (axis1 + 1) % 3;
}
if(axis2 == 0){ //------------------------------
axis2 = 2;} // reverse "(changept2 + 1) % 3"
else{axis2--;} //------------------------------
}
x2[0] = x1[0] + edgeLen;
y2[0] = yy[0] + edgeLen;
z2[0] = z1[0] - edgeLen;
loc = 1;
axis1 = 0;
axis2 = 1;
for(q = 0; q < 3; q++)
{
for(r = 0; r < 2; r++)
{
switch (axis1) {
case 0:
x2[loc] = x2[0] - edgeLen;
y2[loc] = y2[0];
z2[loc] = z2[0];
break;
case 1:
x2[loc] = x2[0];
y2[loc] = y2[0] - edgeLen;
z2[loc] = z2[0];
break;
case 2:
x2[loc] = x2[0];
y2[loc] = y2[0];
z2[loc] = z2[0] + edgeLen;
break;
}
loc++;
switch (axis2) {
case 0:
x2[loc] = x2[loc - 1] - edgeLen;
y2[loc] = y2[loc - 1];
z2[loc] = z2[loc - 1];
break;
case 1:
x2[loc] = x2[loc - 1];
y2[loc] = y2[loc - 1] - edgeLen;
z2[loc] = z2[loc - 1];
break;
case 2:
x2[loc] = x2[loc - 1];
y2[loc] = y2[loc - 1];
z2[loc] = z2[loc - 1] + edgeLen;
break;
}
loc++;
axis2 = axis1;
axis1 = (axis1 + 1) % 3;
}
if(axis2 == 0){ //------------------------------
axis2 = 2;} // reverse "(changept2 + 1) % 3"
else{axis2--;} //------------------------------
}
}
/*
Draws the 3 faces that touch the front bottom left corner
*/
void draw_cube_face()
{
int sidesDrawn1 = 0;
int i;
int a = 0;
float color1[3] = {1.0, 0.0, 0.0};
float color2[3] = {0.0, 1.0, 0.0};
float color3[3] = {0.0, 0.0, 1.0};
while(sidesDrawn1 < 3)
{
glColor3f(color1[sidesDrawn1], color2[sidesDrawn1], color3[sidesDrawn1]);
for(i = 0; i < 2; i++) // allows both triangles on one side to be drawn
{
glBegin(GL_TRIANGLES);
glVertex3f(x1[0], yy[0], z1[0]);
a++;
glVertex3f(x1[a], yy[a], z1[a]);
a++;
glVertex3f(x1[a], yy[a], z1[a]);
glEnd;
}
sidesDrawn1++;
}
}
/*
Draws the 3 faces that touch the back upper right corner
*/
void draw_cube_back()
{
int sidesDrawn2 = 0;
int k;
int a = 0;
float color1[3] = {1.0, 0.0, 0.0};
float color2[3] = {0.0, 1.0, 0.0};
float color3[3] = {0.0, 0.0, 1.0};
while(sidesDrawn2 < 3)
{
glColor3f(color1[sidesDrawn2], color2[sidesDrawn2], color3[sidesDrawn2]);
for(k = 0; k < 2; k++) // allows both triangles on one side to be drawn
{
glBegin(GL_TRIANGLES);
glVertex3f(x2[0], y2[0], z2[0]);
a++;
glVertex3f(x2[a], y2[a], z2[a]);
a++;
glVertex3f(x2[a], y2[a], z2[a]);
glEnd;
}
sidesDrawn2++;
}
}
double transform_eyex()
{
tempx = (cos(theta) * eyex) + (sin(theta) * eyez);
return tempx;
}
double transform_eyez()
{
tempz = (-sin(theta) * eyex) + (cos(theta) * eyez);
return tempz;
}
void display(void)
{
theta += 0.1;
eyex = transform_eyex();
eyez = transform_eyez();
// set up new view
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0, 1.0, 1.0, 10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyex, 5.0, eyez, //eye
0.0, 0.0, 0.0, //target
0.0, 1.0, 0.0); // up
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw triangles
draw_cube_face();
draw_cube_back();
glFlush();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutCreateWindow("cube");
init_mod();
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(display);
glutIdleFunc(glutPostRedisplay);
glutMainLoop();
}

I will try your suggestions.