Game Development Reference
In-Depth Information
Top
Right
Left
Bottom
Far
Near
Eye or Camera
Figure 4-11. The projection frustrum
In terms of code, the function SetCameraProjection() in the Camera class creates the projection
matrix and puts it in the m_ProjectionMatrix variable. See Listing 4-2.
Listing 4-2. Building the Projection Matrix in the Camera Class
void SetCameraProjection(float Projleft,
float Projright,
float Projbottom,
float Projtop,
float Projnear,
float Projfar)
{
m_Projleft = Projleft;
m_Projright = Projright;
m_Projbottom = Projbottom;
m_Projtop = Projtop;
m_Projnear = Projnear;
m_Projfar = Projfar;
Matrix.frustumM(m_ProjectionMatrix, 0,
m_Projleft, m_Projright,
m_Projbottom, m_Projtop,
m_Projnear, m_Projfar);
}
Setting the Viewport
The viewport transformation maps the 2D image generated from the projection matrix to the actual
viewing window. It stretches the image horizontally or vertically to make it fit into the viewport. The
glViewport() function sets the viewport specifications. It is located in the onSurfacedChanged()
 
Search WWH ::




Custom Search