PDA

View Full Version : Screen coords



m.gnu.
07-04-2008, 08:03 AM
Hi,

I'm using gluUnProject to get world coordinates in my app. Let's assume that my rendering window is 100x100, i.e. the mouse position coordinates will range from 0 to 99. As OpenGL has its origin in the bottom left corner I need to do:

mousePnt.y = winSize.y - mousePnt.y

before using gluUnProject. But shouldn't it really be:

mousePnt.y = winSize.y - mousePnt.y - 1

In all tutorials and posts I've seen, people don't have the -1. Maybe I'm just a bit daft...

sharp_pixel
07-04-2008, 08:39 AM
Yes you need the -1 to be accurate.

m.gnu.
07-08-2008, 08:14 AM
Hello again...

When using gluUnProject, are the world coordinates calculated from the center of the input pixel, or the pixel corner? I guess that I will never notice any difference due to the precision, but anyway... I'm just curious.

-NiCo-
07-09-2008, 01:15 AM
Integer coordinates correspond to pixel corners.