Sign in to follow this  
BrentBarrett

How to convert world coords to screen coords?

Recommended Posts

BrentBarrett    154
I'm creating a 2D game using quads and was wondering if anyone knew how to convert each quad's world coords into screen coords. Even though it's a 2D game, I'm using D3DXMatrixPerspectiveFovLH as opposed to D3DXMatrixOrthoLH. So basically, all of the quads are just as they'd be in a 3D game, but I'm wanting to convert their world coords to screen coords(with 0,0 in the top left of screen).

Share this post


Link to post
Share on other sites
OrcishCoder    176
why not use D3DXMatrixOrthoLH? you can get rid of z coordinate and simplify your engine without losing 3D effect.
with ortho,your x,y is meassured as screen pixel. use translation matrix to move your quad across the screen.
If you use D3DXMatrixPerspectiveFovLH,you need to find out magic Z value for different resolution,which quite complicated.
you should use ortho projection if you want to do 2D game. I assume your sprite rotation only surround Z axis as most 2D games did.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this