PDA

View Full Version : Clarification on GL coordinates


LongJumper
2003.10.09, 02:03 PM
If you're facing down the z-axis, at z = 0 the screen is 1 unit across and 1 unit up and down. Therefore, -.5 is the left hand side and +.5 is the right hand side, and similar for the y axis.

This would also mean that if z was pushed one unit into the screen, I could use probably pythaghoweveryouspellit's theorem to figure the amount of units it is across at that point(that are viewable).

And would this also mean that I could take the resolution of monitor(since it is fullscreen) and the global(or local to the fullscreen window?) coordinates of the mouse location to figure out it's GL coordinates?

Correct me on any bad logic :)

DoG
2003.10.09, 02:08 PM
Originally posted by LongJumper

Correct me on any bad logic :)

I would if I could see any ;)

gluUnproject()

Mars_999
2003.10.09, 03:04 PM
I think the problem is when you have different viewing angle the screen doesn't map the same. Correct me if I am wrong on that.

gluPerspective(90.0f, float(width) / float(height), 1.0f, 5000.0f);


The 90.0f if changed to 45.0f makes a huge delta

LongJumper
2003.10.10, 02:53 PM
Got it nearly working, I wrote up an equation that will calculate how far the window is into the screen to figure out how big it appears on the screen, so that I can check for clicks inside it.

Basically, since the closest it can be to the screen is z = -1 and the further it can be is the far projection of the camera... it comes out to be: x = windowWidth - (windowWidth/farProjection)*(z+1);

Now, with glGetDoublev, what parameters do I need to supply it with to receive the far projection of the camera, and since the last time the screen was rendered was by the current camera(I don't think it will ever need another camera..?) will it automatically grab that camera's projection?