Jump to content
  • Advertisement
Sign in to follow this  
Simplicity

Different Projection Calculation

This topic is 4552 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

Why does D3DX and GLU calculates the projection matrix differently? D3DXMatrixPerspectiveFovRH (converted to column major): xScale 0 0 0 0 yScale 0 0 0 0 zf/(zn-zf) zn*zf/(zn-zf) 0 0 -1 0 where: yScale = cot(fovY/2) xScale = yScale / aspect ratio gluPerspective: xScale 0 0 0 0 yScale 0 0 0 0 zf+zn/(zn-zf) 2*zf*zn/(zn-zf) 0 0 -1 0 where: yScale = cot(fovY/2) xScale = yScale / aspect ratio D3DXMatrixOrthoRH (converted to column major ): 2/w 0 0 0 0 2/h 0 0 0 0 1/(zn-zf) zn/(zn-zf) 0 0 0 l glOrtho: 2/w 0 0 tx 0 2/h 0 ty 0 0 -2/(zf-zn) tz 0 0 0 l where: w = right - left; h = top - bottom tx = -( right + left ) / w ty = -( top + bottom ) / h tz = -( zf + zn ) / ( zf - zn ) So if I want to make an engine that can switch back and forth between D3D and OpenGL, projection matrix generation has to be API specific? What about for view matrix?

Share this post


Link to post
Share on other sites
Advertisement
Quick answer:

1. The projection matrices differ in the handedness, and in the z-clipping range
2. The view matrix constructed by the 'look at' functions differ in the handedness
3. The DX library includes functions for both left- and right-handed versions of both, I believe

Share this post


Link to post
Share on other sites
If you've already accounted for handedness and vector orientation, the remaining differences in the projection matrices are due to z-clipping range ([0, 1] in D3D, [-1, 1] in OpenGL).

Also, earlier you mentioned converting the matrices to 'column major', but the correct term is 'column vectors' (a common mistake).

Share this post


Link to post
Share on other sites
If you've already accounted for handedness and vector orientation, the remaining differences in the projection matrices are due to z-clipping range ([0, 1] in D3D, [-1, 1] in OpenGL).

Also, earlier you mentioned converting the matrices to 'column major', but the correct term is 'column vectors' (a common mistake).

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!