Usual way:
- create orthogonal projection matrix (
XMMatrixOrthographicLH()
if you using XMMATH) - create constant buffer with this matrix on CPU side (C++ code) and on GPU size (vertex shader)
- multiply vertex positions by orthogonal projection matrix in vertex shader
- create orthogonal projection matrix (
Simpler way (from F.Luna book):
XMFLOAT3 SpriteBatch::PointToNdc(int x, int y, float z) { XMFLOAT3 p; p.x = 2.0f*(float)x/mScreenWidth - 1.0f; p.y = 1.0f - 2.0f*(float)y/mScreenHeight; p.z = z; return p; }
Almost the same, but on CPU side. Of course, you can move this code to shader too.
P.S. Probably your book/manual/tutorials will learn you about it a little later. So, you better trust it and flow step-by step.
Happy coding! =)