PDA

View Full Version : Vary level of perspective



skorulis
06-16-2010, 06:11 PM
I'm currently drawing a cube on the screen that takes up most of the screen. This means that when the user rotates the cube the corners come very close to the eye and the perspective of the cube is highly visible. I would rather this not happen. Is there a way in openGL to vary how much perspective there is in a scene, so how quickly straight lines converge. I don't want to use orthographic projection as it just looks wrong.
This site (http://webkit.org/blog-files/3d-transforms/perspective-by-example.html) demonstrates what I am after in css(webkit only), can something similar be done in openGL?

Extra information: Currently drawing on an iphone using openGL ES.

Dark Photon
06-17-2010, 05:17 AM
Is there a way in openGL to vary how much perspective there is in a scene, so how quickly straight lines converge.

Of course.

http://www.songho.ca/opengl/files/gl_projectionmatrix01.png

Look at the left diagram. These correspond to glFrustum parameters. You want the sides to be slanted less. How do you get that? Pull l,r,b,t in closer to 0. Or if you're using the gluPerspective helper, reduce fovy down. And push your object further away from the eyepoint.