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