Screen coords


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…

Yes you need the -1 to be accurate.

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.

Integer coordinates correspond to pixel corners.