View Full Version : find the corners of the screen at a given depth?

11-12-2013, 03:46 PM

If I have a rectangle facing the screen in my scene, how can I determine the four corners so that it fills the screen exactly? In other words I think I want the four points where the plane of this rectangle intersects the viewing frustum.
I have some code that finds the eight corners of the entire frustum, so I should be able to intersect those planes with my rectangle's. But I was wondering if there is a simpler way, where I don't have to go through the math to get the whole frustum.


11-12-2013, 04:43 PM
Why not use an orthographic projection matrix?

11-13-2013, 02:51 AM
If you generated the projection matrix with gluPerspective, then the top and bottom edges of the screen have y/z=ħtan(fovy/2), and the left and right edges have x/z=ħaspect*tan(fovy/2).

If you used glFrustum() then the left edge has x/z=left/nearVal, similarly for the other three edges.