3D applications usually try to simulate the effect of how we perceive the world around us--objects in the distance seem smaller than the objects that are closer to us. To achieve this effect, we need to use a perspective projection matrix.
Preparing a perspective projection matrix
How to do it...
- Prepare a variable of type float named aspect_ratio that will hold an aspect ratio of a renderable area (image's width divided by its height).
- Create a variable of type float named field_of_view. Initialize it with an angle (in radians) of a vertical field of view of a camera.
- Create a variable of type float named near_plane and initialize it with the distance from the camera's position to the near clipping plane.
- Create a variable of type float named far_plane...