2012-12-27 68 views
0

我需要在DirectX 9中繪製一些東西。 我有興趣以座標調整爲像素的方式工作,而(0,0)將是TopLeft一角。這是我做的:如何在DirectX 9中設置左上角座標?

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); 

這工作正常,但在(0,0)是BOTTOMLEFT角落。我該如何改變它? 謝謝!

+0

交換底部和頂部在D3DXMatrixOrthoOffCenterLH: D3DXMatrixOrthoOffCenterLH(&matOrtho2D,0,clientRect.right,clientRect.bottom,0,0.0F,1.0F); – Dave

回答

0

這應該是添加操作的代碼:

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); 
相關問題