5.6.3.6 XMMatrixPerspectiveFovLH A perspective projection matrix can be built with the following XNA Math function: XMMATRIX XMMatrixPerspectiveFovLH( // returns projection matrix FLOAT FovAngleY, // vertical field of view angle in radians FLOAT AspectRatio,
// aspect ratio = width / height FLOAT NearZ, // distance to near plane FLOAT FarZ); // distance to far plane The following code snippet illustrates how to use D3DXMatrixPerspectiveFovLH. Here, we specify a 45° vertical field of view, a near plane at z = 1,
and a far plane at z = 1000 (these lengths are in view space).
XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathX::Pi, AspectRatio(), 1.0f, 1000.0f); The aspect ratio is taken to match our window aspect ratio: float D3DApp::AspectRatio()const { return static_cast<float>(mClientWidth) / mClientHeight; }