I'm only really use OpenGL ES for mobile devices, so don't quote me, but I think your keyboard procedure is the problem. You shouldn't be calling glTranslatef from inside the keyboard proc, because that one matrix will end up being applied to the entire scene. You have make your keyboard procedure store a position in the form of a vector, and then fetch that vector from your display procedure. Once you do that, then you have to fix your display procedure to have one call of glTranslatef per object in your scene(one for the cube, and one for the sphere). One of those translations of course will contain the information you stored in the vector from your keyboard procedure, and the other one will contain the world position of the cube.
example:
Vector3f spherePosition(10.0f, 5.0f, -10.0f); //initial position of sphere
void keyboard(unsigned char key, int x, int y)
{
KeySet();
if(key == 27) exit (0);
//I dont know which keycode is which letter =/
else if( (key == 119) && (95 > spherePosition[0]) )
{
spherePosition[0] += 1;// +X
}
else if( (key == 115) && (spherePosition[0] > -95) )
{
spherePosition[0] -= 1;// -X
}
else if( (key == 97) && (spherePosition[2] > -95) )
{
spherePosition[2] -= 1;// -Z
}
else if( (key == 100) && (95 > spherePosition[2]) )
{
spherePosition[2] += 1; // +Z
}
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix(); //store the active matrix so that we can use ours
glTranslatef(spherePosition[0], spherePosition[1], spherePosition[2]);
glColor3f (0, 0.2, 1);
glutWireSphere(5, 10, 10);
glTranslatef(10, 0, -10);
glRotatef(angle, 0, 0.5, 1);
glColor3f (1, 0, 0);
glutWireCube(5);
glPopMatrix(); //put things back the way they were when we are done
glutSwapBuffers();
} I think that should do it...someone correct me if I'm wrong here =D