If you have two cubes moving (differently) in a 3D world and if you to look at the first one (moving in a spherical path), you can use the glulookat function.
The camera is centered in the world, moving in a spherical path you’r camera is like moving the entire world around its center, u see what i mean ?
If you don’t see what does the glulookat function, u can also use gltranslate and glrotate to do this. If you’r looked object is A(xa, ya,za), do:
//**** the camera is centered in the world
gltranslatef(xa, ya, za);
//**** it’s stil centered in the world but you can imagine it’s the camera whitch is moving inthe world
glrotatef(xangle, 1.f, 0.f, 0.f);
glrotatef(yangle, 0.f, 1.f, 0.f);
glrotatef(zangle, 0.f, 0.f, 1.f);
glTranslatef(-xa, -ya, -za);
or you can use the glulookat (don’t forget to determine the look up axe !!! )
Hope that helped