I'm working in C++ with DirectX 9 on a 3D game, but I want a 2D overlay for rendering a HUD.
I've heard that I could use D3DXMatrixOrthoLH, but I'm very confused on how to use it. I'm more familiar with OpenGL, where I could simply switch between 3D and 2D by initiating the view.
How can I do this in DirectX 9?
EDIT:
I was able to achieve this like (partial psudocode):
But I have a good feeling this is not the right way to do it.
void render() { beginscene(); D3DXMATRIX matrix; D3DXMatrixIdentity(&matrix); D3DXMatrixTranslation(&matrix, 0, 0, 0); device->SetTransform(D3DTS_WORLD, &matrix); // Render 3D. D3DXMatrixIdentity(&matrix); device->SetTransform(D3DTS_WORLD, &matrix); device->SetTransform(D3DTS_VIEW, &matrix); D3DXMatrixOrthoOffCenterRH(); device->SetTransform(D3DTS_PROJECTION, &matrix); // Render 2D. endscene(); }