# Changing map 0,0 origin to top left while using D3DXMatrixOrthoLH

Thanks to Tetrad (for pointing out D3DXMatrixOrthoLH ) I have figured out how to set it up in DirectX9. However, the problem I am now facing is my 0,0 mouse position is now in the middle.

What I Want To Achieve: I want my 0,0 origin to be the top left of the window (not the middle). I also want to be able to zoom in.

Thanks for any help!

edit (this seems to add the 0,0 to the bottom left)

D3DXMATRIX m_d3dts_projection;
D3DXMatrixOrthoOffCenterLH ( &m_d3dts_projection , 0.0f , console_editor.window_w , 0.0f , console_editor.window_h , 1.0f , 10.0f );
console_editor.directx_device->SetTransform ( D3DTS_PROJECTION , &m_d3dts_projection );


I have been developing a map editor in C++ DX9 for the past couple of months, and have ran into a particular development problem.

How my map editor works: I split the screen into 16x16 cell blocks each with their own struct for rendering. When you click on the window, it will find the cell block that you clicked based on the win32 whereabouts of the mouse cursor. It then will do its magic. This seems to work well with a FOV of D3DXToRadian(float 90).

However!

I also want my map editor to be able to zoom in and to zoom out, so when I increase or decrease the FOV, the mouse cursor and the cell block code are all correct, but wrong. Example:

Normal 90 FOV - Looks Good

Zoomed In - Opps

Question: How can I add functionality of zooming in and out, but still have the mouse position be relevant to the render? I assume I have to recode how everything works, and I am okay with doing that...

• Usually for these kinds of things you don't use a perspective camera and instead use an orthographic camera. So you'd pass in an orthographic size instead of an FOV. It might make some of your math easier. – Tetrad Apr 18 '13 at 22:20
• @Tetrad Oh, Ive never done anything with D3DXMatrixOrthoLH before. Ive looked it up, but cant seem to get it working. Do you have sample source code on how to set it up? – User Apr 20 '13 at 2:42
• Read the documentation, you'll find D3DXMatrixOrthoOffCenterLH - msdn.microsoft.com/en-us/library/windows/desktop/… – Maximus Minimus Apr 20 '13 at 21:48
• @mh01 Thank you! Ill check it out, looks like what I need. – User Apr 21 '13 at 2:24
• @mh01 Seems to place the 0,0 in the bottom left. See above code. – User Apr 21 '13 at 3:50