2
votes

I am converting my OpenGL engine to DirectX11. I used GLM in OpenGL, and will continue in Directx if possible. One problem I have however is constructing the perspective matrix using the glm::perspective

OpenGL maps [-1, 1] whereas DirectX maps [0, 1]. Is there any easy fix for this? I'd rather not switch math library just because of this.

2
Just build your own perspective matrix. Check this out: songho.ca/opengl/gl_projectionmatrix.html - dari

2 Answers

0
votes

See this http://msdn.microsoft.com/en-us/library/windows/desktop/bb205350(v=vs.85).aspx This is a built in function for Direct3D/X for constructing the matrix

0
votes

You either use DirectXMath's XMMatrixPerspectiveFovRH (for right-handed view systems) or XMMatrixPerspectiveFovLH (for left-handed setups). With the Direct3D 9 legacy fixed-function pipeline you have to use LH. For programmable shaders, it's up to you by DirectX apps are often LH, while OpenGL apps are often RH. See the DirectXMath programmer's guide for more on this.

If using the legacy DirectX SDK without the Windows 8.0 SDK or Windows 8.1 SDK, you can make use of XNAMath which is very similar to DirectXMath.