Code behind D3DXMatrixPerspectiveFovLH?

Started by
1 comment, last by Burnt_Fyr 13 years ago
I am converting my graphics over to OpenGL and already rebuilt all major matrix functions except D3DXMatrixPerspectiveFovLH. I was able to find this and tried to convert it to work with my matrices but I don't think I did it right:



Ovgl::Matrix44 Ovgl::MatrixPerspectiveLH( float ViewWidth, float ViewHeight, float NearZ, float FarZ)
{
Ovgl::Matrix44 out = {0};

float depth = FarZ - NearZ;
float q = -(FarZ + NearZ) / depth;
float qn = -2 * (FarZ * NearZ) / depth;
float w = 2 * NearZ / ViewWidth;
float h = 2 * NearZ / ViewHeight;

out._11 = w;
out._12 = 0;
out._13 = 0;
out._14 = 0;

out._21 = 0;
out._22 = h;
out._23 = 0;
out._24 = 0;

out._31 = 0;
out._32 = 0;
out._33 = q;
out._34 = -1;

out._41 = 0;
out._42 = 0;
out._43 = qn;
out._44 = 0;

return out;
}



Does anyone know how D3DXMatrixPerspectiveFovLH works?
Advertisement
Yes, MSDN. You'll find that all D3DX matrix methods are explained in how they calculate the matrix fields.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>


Yes, MSDN. You'll find that all D3DX matrix methods are explained in how they calculate the matrix fields.


One thing to look out for is the difference between right and left handed coords, which affect your view and projection matrices. If you are working with a right handed coordinate system, you would want to use D3DXLookAtRH.

This topic is closed to new replies.

Advertisement