mouse dragging - help

I have the following code for mouse dragging but it isn’t working - help

GLint viewport[4];
GLdouble modelMatrix[16];
GLdouble projMatrix[16];

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

glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);

//get 2D projection 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);
float depth;
int nPixelSize = 3;
glRasterPos3f((float)xWorld, (float)yWorld, (float)zWorld);
glDrawPixels(nPixelSize, nPixelSize, GL_RGB, GL_FLOAT, &depth);

I wanting to also ask - with mouse dragging you should be able to select and drag an object - at the moment I have this as a separate function to rotation, zooming etc. is this right?

cheers

What is the advantage of using the gluUnproject to accomplish this instead of the selection buffer? It was fairly easy to do using the select buffer, but for a big scene, it can become prohibitively slow… I’ve never looked into using unproject.

Chris

Hi Chris
well I had implemented a version of selection buffer which worked - it actually output message of which object was selected - but i couldn’t go beyond that i.e. select an object and then use my rotate, zoom, or pan code - maybe I’ll e-mail you some code to have a look

cheers