View Full Version : Screen coords

07-04-2008, 07:03 AM

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...

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

07-08-2008, 07: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.

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