Yeah I think dezzroy is starting to understand it.
Now for a more complete answer:
(bearing in mind that you haven’t stated what happens and what you were expecting)
You’re doing this:
glLoadIdentity()
glPushMatrix()
glTranslatef()
(call drawCube())
glPushMatrix() //Save any transformations
glLoadIdentity() //Reset Matrix
glPushMatrix()
glTranslate()
DrawSide()
glPopMatrix()
glPopMatrix() //Restore transformations
(return)
glPopMatrix()
What I think you were expecting, but aren’t getting, is a cube at a different location than (0,0,0). That is because the glLoadIdentity in your drawcube function, resets the transformation matrix.
If you remove that glLoadIdentity, that issue should be solved. As for the sides of the cube: you have not posted the drawside function, but my guess is that you always send the same vertices in that function, and in that case you’ll need to do something like:
(drawcube function)
glPushMatrix()
// no glrotate here since this is the "front" face
glTranslate()
DrawSide()
glPopMatrix()
glPushMatrix()
glRotate(90,0,1,0) // one of the sides
glTranslate()
DrawSide()
glPopMatrix()
glPushMatrix()
glRotate(180,0,1,0) // another side
glTranslate()
DrawSide()
glPopMatrix()
// etc.
All things considered, it’s probably easier to just use a bunch of glVertex calls - there are only 8 vertices in a cube, and it’s easier to specify them directly than it is to use glTranslates and glRotates.
So something like:
(drawcube function)
glBegin(GL_QUADS);
// first side
glVertex3f( 1, 1, 1);
glVertex3f( 1,-1, 1);
glVertex3f(-1,-1, -1);
glVertex3f(-1, 1, 1);
// second side
glVertex3f( ... // etc.
glEnd();
// note: no push/pop necessary. Caller decides
// on scale, location and rotation.