Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

silversaraph

How to draw a polygon at the edge of the screen?

This topic is 5274 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

after using gluPerspective(60.0f,(GLfloat)800/(GLfloat)600,0.1f,100.0f) in a 800 x 600 window, how to draw a quad that with it's top-left point at the top-left point of the window screen? how to calculate it, thank you? [edited by - silversaraph on February 7, 2004 8:17:35 PM]

Share this post


Link to post
Share on other sites
Advertisement
Highest visible point in frustrum at distance d:
[1] y = tan(fovy) * d

Leftmost visible point in frustrum at distance d:
[2] x = -tan(fovx) * d

You already have fovy. To calculate tan(fovx):
[3] fovy = atan(height / distance)
[4] fovx = atan(width / distance)
[5] tan(fovy) = height / distance (rearrangement of 3)
[6] tan(fovx) = width / distance (rearrangement of 4)
[7] distance = height / tan(fovy) (rearrangement of 5)
[8] tan(fovx) = width / (height / tan(fovy)) (7 into 6)
[9] tan(fovx) = (width * tan(fovy)) / height (rearrangement of 8)
[10] tan(fovx) = tan(fovy) * (width / height) (rearrangement of 9)


Enigma

Share this post


Link to post
Share on other sites
It was late and I read his post and just assumed he really wanted to be able to position something at an absolute position under a perspective projection. Reading it again it''s quite possible that an orthographic projection would have been the simplest answer. Just goes to show that if you''re not careful how you specify your question you might not get the best answer!

Enigma

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!