View Full Version : gluProject and y coords...
02-12-2005, 01:07 AM
Plzm explain me one thing. So
I have world coord (0,0). And this code give me result (320,63)
double modelMatrix; double projMatrix; int viewport;
double objx; double objy; double objz;
float x_; float y_; float z_;
gluProject(vx, vy, 0, modelMatrix, projMatrix, viewport, &objx, &objy, &objz);
x_ = float(objx);
y_ = float(objy);
z_ = float(objz);
How to make so, that I got (320,240), e.g. the centre?
02-13-2005, 01:23 AM
It all depends on how you setup your projection/modelview matrix, if you use orthographic projection you can map the world coordinates (almost) anyway you want, have a look at the FAQ on this website it explains most of the details of how to do it.
Your example does not include how you setup the projection/modelview matrix so it is impossible to answer why you get the coordinates you say.
02-13-2005, 01:41 PM
glViewport(0, 0, width, height);
02-13-2005, 10:59 PM
So wx and wy is 0 ?, if you have not modified the modelview matrix, that might be the problem, the "camera" is at 0,0,0 and you try to project the point at 0,0,0, this is also outside the near clipping plane, so if you try to move the "camera" away from the origin a little it might work better, use glTranslate(0,0,z)
As you are using perspective mode you always have to be careful with the Z value, you do get a perfect 320,240 match at the origin until you move the "camera", then it will no longer work.
02-14-2005, 04:36 AM
ok, i have add a LoadIdentity before and in 0,0 I got 320,240. I use Z=0 in gluProject.
But than I have very big numbers.
vx= 0 x_=320
vy= -15 y_=9047
vx= 7,6 x_=-4086 (why minus?)
vy= 0,1001 y_=234.2
I tried to change z to 1,0,-1,0.1, but nothing good.
02-17-2005, 10:42 AM
plz, help anybody...
I semd to you small CPP project with problem...
My ICQ: 149448686
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.