D3D and OpenGL projection matrices
Hi!
Why D3D and OpenGL have different projection matrices ?
Basically, functions that create this projection matrices has same IN parameters:
(fov, aspect, z_near, z_far) but math behind creating this matrix is little bit different.
Thx for answers.
They don't have different projection matrices. What you are talking about is handedness (right and left) of matrices and coordinate systems. The right and left handedness are mere conventions. To say that one is different from the other is wrong. It is up to you to decide which one (handedness) you want to use. Direct3D offers APIs to create both types.
D3DXMatrixPerspectiveFovLH - Left handed.
D3DXMatrixPerspectiveFovRH - Right handed.
True, OpenGL doesn't offer an API for left-handed system out of the box, or rather GLU doesn't, but you can write your own function to create a left-handed matrix for OpenGL.
If you set left-handed matrices, you can make OpenGL behave exactly like Direct3D or vice-versa.
D3DXMatrixPerspectiveFovLH - Left handed.
D3DXMatrixPerspectiveFovRH - Right handed.
True, OpenGL doesn't offer an API for left-handed system out of the box, or rather GLU doesn't, but you can write your own function to create a left-handed matrix for OpenGL.
If you set left-handed matrices, you can make OpenGL behave exactly like Direct3D or vice-versa.
D3D maps the depth 0.0 to 1.0 while GL maps to -1.0 to 1.0 and then remaps to 0.0 to 1.0 using another functionality (glDepthRange)
Don't worry, you don't lose performance.
D3DX also has 2 functions. One for right handed and another for left.
I think that element [3][3] of the D3DX projection matrix version is incorrect.
It is zf/(zn-zf) instead of (zf+zn)/(zn-zf)
Don't worry, you don't lose performance.
D3DX also has 2 functions. One for right handed and another for left.
I think that element [3][3] of the D3DX projection matrix version is incorrect.
It is zf/(zn-zf) instead of (zf+zn)/(zn-zf)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement