Here is the pseudo code:
void render(void) // display callback
glutSolidCube(side); //or whatever it may be
void mouse(int mx,int my) //mouse callback
// here my approach goes like this.
// I feel I need to consider the local origin wrt the cube
// as my point of convergence of the 3 axes
// For instance if my resolution is say 800x600 and
// assume the object is at the center of my viewport which
// spans across the whole screen. then my origin wrt
// the viewing area is (400,300)(screen coordinates).
// Now when we obtain the mouse coordinates on the screen
// we find its coordinates wrt the new origin (400,300)
// by doing x = x - 400 and y = y - 300
// and assume a unit circle rotation here, ie
// anglex = arccos(x) and angley = arcsin(y)
// and I am utterly lost when it comes to z-axis rotation
PS: sorry I dont have my PC with me right now so i had to cook up this pseudo code.