yet another gluUnProject question...

Hi all, I’ve searched the forums and looked at the Red Book example but still can’t figure out what is going wrong with my program so I thought I make yet another post about gluUnProject(), which i guess can be tricky to use…

Here’s what I’m trying to do: I would like to drag points in 3d world but the z-value is fixed (so i guess i won’t need glreadpixel). but of course it didn’t work. the unprojected values only change by super small fractions! however, it seems that if I scale up the mouse positions by like 1000 then I get some movements, so could it be that I’m not taking into account the camera orientations? (I need to zoom out quite a bit.) The code is as follows:

GLdouble model[16], proj[16];
GLint view[4];

double wx, wy, wz;

glGetDoublev(GL_PROJECTION_MATRIX, proj);
glGetDoublev(GL_MODELVIEW_MATRIX, model);
glGetIntegerv(GL_VIEWPORT, view);

cerr << "mouse pos: " << m_lastMouseX << " " << (h() - m_lastMouseY) << endl;

gluUnProject((double)m_lastMouseX, (double)(h() - m_lastMouseY), 0, model, proj, view, &wx, &wy, &wz);

cerr << "unprojected to: " << “(” << wx << ", " << wy << ")
";

Markers.pos[0] = wx;
Markers.pos[1] = wy;
Markers.pos[2] = some fixed value

I printed out the view and projection matrices:

modelview:
1 0 0 0
0 0.999994 -0.00333332 0
0 0.00333332 0.999994 0
-14.1621 -8.28815 -39.5964 1

projection:
3.73205 0 0 0
0 3.73205 0 0
0 0 -1 -1
0 0 -0.02 0

and they agree with the ones i used for drawing… Anyway anybody got some ideas or perhaps alternatives to dragging points on screen?

any help would be greatly appreciated as i’m getting increasingly frustrated by this bug…

I don’t really understand what you want to do but have you tried searching this forum for “gluUnProject” ?
There’s been a few discussions about all this around here before.

fritzlang

(Searching on “gluUnProject” gave me 82 topics)

[This message has been edited by fritzlang (edited 12-11-2002).]