Rotating an object around any desired point using mouse.

Hello everyone.
I want to know that how i can rotate an object about a point where I click on the screen.
Currently I am able to rotate it about the center of the screen.

My code is as following. Please suggest a simple way to modify this for the desired results.

void mouse(int button, int state, int x, int y)
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
mouseDown = true;

xdiff = x - yrot;
ydiff = -y + xrot;
mouseDown = false;

void mouseMotion(int x, int y)
if (mouseDown)
yrot = x - xdiff;
xrot = y + ydiff;


and these lines in my display function:
glRotatef(xrot, 1.0f, 0.0f, 0.0f);
glRotatef(yrot, 0.0f, 1.0f, 0.0f);

Please help.

You need to translate the origin to the point, apply the rotate then translate the origin back

ok. how to get the coordinates of that point?

A point on the screen is actually a line in 3D. You are best to do a google on picking in 3D because it is a topic with a lot of solutions all of which have limitations.