The SetPerspectiveProjection function sets the given matrix to a perspective transform for the given half-height and front- and back-clipping planes. This function is called as part of the CreateScene function, documented in Creating the Scene.
static void
SetPerspectiveProjection(LPD3DMATRIX lpd3dMatrix,
double dHalfHeight,
double dFrontClipping,
double dBackClipping)
{
double dTmp1;
double dTmp2;
ASSERT(NULL != lpd3dMatrix);
dTmp1 = dHalfHeight / dFrontClipping;
dTmp2 = dBackClipping / (dBackClipping - dFrontClipping);
lpd3dMatrix->_11 = D3DVAL(2.0);
lpd3dMatrix->_12 = D3DVAL(0.0);
lpd3dMatrix->_13 = D3DVAL(0.0);
lpd3dMatrix->_14 = D3DVAL(0.0);
lpd3dMatrix->_21 = D3DVAL(0.0);
lpd3dMatrix->_22 = D3DVAL(2.0);
lpd3dMatrix->_23 = D3DVAL(0.0);
lpd3dMatrix->_24 = D3DVAL(0.0);
lpd3dMatrix->_31 = D3DVAL(0.0);
lpd3dMatrix->_32 = D3DVAL(0.0);
lpd3dMatrix->_33 = D3DVAL(dTmp1 * dTmp2);
lpd3dMatrix->_34 = D3DVAL(dTmp1);
lpd3dMatrix->_41 = D3DVAL(0.0);
lpd3dMatrix->_42 = D3DVAL(0.0);
lpd3dMatrix->_43 = D3DVAL(-dHalfHeight * dTmp2);
lpd3dMatrix->_44 = D3DVAL(0.0);
}