Advertisement Jump to content
Sign in to follow this  

How To Use Dx Ortho Projection Matrix

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

What difference between XMMatrixOrthographicOffCenterLH and XMMatrixOrthographicLH? 

I have use this api to make a ortho projection matrix, but don't know how to set the view point. 

Though I know the XMMatrixOrthographicOffCenterLH  uses parameters from   a box around the view point , 


 when I am going to make view matrix, whether should I need to set the view point behind the box ? or remain the view point at the middle of 

the box?

Edited by poigwym

Share this post

Link to post
Share on other sites
TLDR: use XMMatrixOrthographicOffCenterLH if you don't need to move a camera as this is simpler and it's one less matrix multiplication to do (since you don't need a view matrix) Otherwise you will have to use XMMatrixOrthographicLH and also provide your own view matrix.

I was going to post something yesterday but I wasn't 100% sure I was correct but seen as you haven't had many responses I'll post anyway but bare in mind I might be slightly off.

Both are creating an orthogonal projection but one is more flexible than the other. XMMatrixOrthographicOffCenterLH essential also contain your 'view' position, it will move your camera to the centre of the area you define. For example, if you set the left to 0 and the right to 800 then it should (I believe..) make it such that the left is 0, the right is 800 (unsurprising) and your camera is at 400. You don't really need a 'view' transform with it. That is probably the better choice for you if you have a static 2D game/window without scrolling.

XMMatrixOrthographicLH almost does the exact same thing but it doesn't contain a 'view' (well it kinda does with the z axis). If you set width to be 800 then the left of your screen will be -400 and the right of your screen will be 400. It will make it such that your 'view' s at 0,0. That will be good if you intend to have your own view transform that you want to move around yourself such as a side scrolling platform type game.

You can see what is happening from the links that NikitaBlack provided. The bottom row can be thought of as the translation, for XMMatrixOrthographicLH the x/y values of that are set as 0 but they are not for XMMatrixOrthographicOffCenterLH . You could use XMMatrixOrthographicOffCenterLH to create the same matrix by using left=-400, right = 400.

The third column/fourth row element looks different in both zn/(zn-zf) versus -zn/(zf-zn) but actually they are exactly the same if you rearrange them algebraically. Not sure why they are arranged differently there. Edited by Nanoha

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!