Jump to content
  • Advertisement
Sign in to follow this  

OpenGL DirectX 11 coordinate system question

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

How do I make the coordinate system in DirectX 11 relative to the top left of the screen? I've setup an orthographic projection matrix, so that I can use screen coordinates but it makes more sense to me to have a top left origin, since I come from working with OpenGl.

I setup my projection matrix like this:
ww = the width of the window
and wh = the height of the window

projection = XMMatrixIdentity ();
projection = XMMatrixOrthographicLH (ww, wh, -1, 1);
Edited by Lyev

Share this post

Link to post
Share on other sites
The Direct3D post-projective normalized viewport coordinate space spans from [-1, 1] in X direction, +X being towards right, and [-1, 1] in Y direction, +Y being towards the top of the screen. See http://msdn.microsoft.com/en-us/library/windows/desktop/cc308049(v=vs.85).aspx
Assuming vector*matrix transformation order, to make an orthographic space that has (0,0) as top-left and (1,1) as bottom-right, (and depth range of [0,1]) you can use the matrix:

2 0 0 0
0 -2 0 0
0 0 1 0
-1 1 0 1

If you use matrix*vector, transpose the above matrix.

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!