Jump to content
  • Advertisement
Sign in to follow this  
DimaSi

OpenGL D3D and OpenGL projection matrices

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!