Pro OpenGL ES for iOS

(singke) #1

CHAPTER 2: All That Math Jazz (^45)
In perspective projection, the distance component, z, is used to scale what will
ultimately be the screen x and screen y values. So, the larger the z, or the distance away
from the viewer, the smaller the pieces are visually. What one needs is the dimension of
the viewport (OpenGL’s version of your window or display screen) and its center point,
which is typically the origin of the XY plane.
This final phase involves setting up the viewing frustum. The frustum establishes six
clipping planes (top, bottom, left, right, near, and far) needed to precisely determine
what should be visible to the user and how it is projected onto their viewport, which is
OpenGL’s version of your window or screen. This acts something like a lens into your
OpenGL virtual world. By changing the values, you can zoom in or out and clip stuff
really far away or not at all, as shown in Figures 2-9 and 2-10. The perspective matrix is
defined by these values.
Figure 2-9. Narrow bounds for the frustum give you a high-power lens.
Figure 2-10. Wider bounds are like a wide-angle lens.

Free download pdf