0

I need to draw something in DirectX 9. I am interested to work in a way that the coordinates will be adjusted to pixels, while (0,0) will be the TopLeft corner. Here is what I do:

RECT clientRect;
::GetClientRect(m_hWIN, &clientRect);

D3DXMATRIX matOrtho2D, matIdentity;    

D3DXMatrixOrthoOffCenterLH(&matOrtho2D, 0, clientRect.right, 0, clientRect.bottom, 0.0f, 1.0f);
D3DXMatrixIdentity(&matIdentity);

g_pDirect3D_Device->SetTransform(D3DTS_PROJECTION, &matOrtho2D);
g_pDirect3D_Device->SetTransform(D3DTS_WORLD, &matIdentity);
g_pDirect3D_Device->SetTransform(D3DTS_VIEW, &matIdentity);

This works fine, except the (0,0) is the BottomLeft corner. How can I change it? Thanks!

selbie
  • 100,020
  • 15
  • 103
  • 173
Iron-Eagle
  • 1,707
  • 2
  • 17
  • 34
  • swap bottom and top in D3DXMatrixOrthoOffCenterLH: D3DXMatrixOrthoOffCenterLH(&matOrtho2D, 0, clientRect.right, clientRect.bottom, 0, 0.0f, 1.0f); – Dave Dec 27 '12 at 21:27

1 Answers1

0

This should be add to code:

D3DXMATRIX matTranslate, matFlip;  

D3DXMatrixTranslation(&matTranslate, 0, clientRect.bottom, 0.0f);
D3DXMatrixRotationX(&matFlip, D3DXToRadian(180));
D3DXMATRIX matCoordTransform = matFlip * matTranslate;

g_pDirect3D_Device->SetTransform(D3DTS_WORLD, &matCoordTransform);
Iron-Eagle
  • 1,707
  • 2
  • 17
  • 34