dragging objects under a mouse

Hi I have the following code for dragging object under the mouse - it isn’t working at the moment - how could I modify it so it does?

pickObjects( int x, int y)
GLdouble modelMatrix[16];
GLdouble projMatrix[16];
GLint viewport[4];
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_MODELVIEW_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);

GLdouble winx =3.0f, winy=-1.5, winz=-1.5;

//get 2D projection of of cube
GLdouble xScreen, yScreen, zScreen;
gluProject(winx, winy, winz,
modelMatrix, projMatrix, viewport,
&xScreen, &yScreen, &zScreen);

x =(int)xScreen;
y = (int )yScreen;

//offset to allow pixel block to be centred around actual position
xScreen -=0.5f;
yScreen -=0.5f;

//do inverse transform
double xWorld, yWorld, zWorld;
gluUnProject(xScreen, yScreen, zScreen,
modelMatrix, projMatrix, viewport,
&xWorld, &yWorld, &zWorld);
void* pixels=NULL;
int nPixelSize = 3;
glRasterPos3f((float)xWorld, (float)yWorld, (float)zWorld);
glDrawPixels(nPixelSize, nPixelSize, GL_RGB, GL_FLOAT, pixels);