简体   繁体   English

如何在DirectX 9中设置左上角坐标?

[英]How to set top-left coordinates in DirectX 9?

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. 我需要在DirectX 9中绘制一些东西。我很感兴趣以一种方式将坐标调整为像素,而(0,0)将成为TopLeft角。 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. 除(0,0)是BottomLeft角外,其他方法都可以正常工作。 How can I change it? 我该如何更改? Thanks! 谢谢!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM