# OpenGL Code behind D3DXMatrixPerspectiveFovLH?

This topic is 2678 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

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

##### Share on other sites

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.

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5

• 14
• 13
• 14
• 75
• 22
• ### Forum Statistics

• Total Topics
632145
• Total Posts
3004341

×