Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/146.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在DirectX 9中设置左上角坐标?_C++_Windows_Directx_Directx 9 - Fatal编程技术网

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

C++ 如何在DirectX 9中设置左上角坐标?,c++,windows,directx,directx-9,C++,Windows,Directx,Directx 9,我需要在DirectX 9中绘制一些东西。 我感兴趣的是将坐标调整为像素,而(0,0)将是左上角。以下是我的工作: RECT clientRect; ::GetClientRect(m_hWIN, &clientRect); D3DXMATRIX matOrtho2D, matIdentity; D3DXMatrixOrthoOffCenterLH(&matOrtho2D, 0, clientRect.right, 0, clientRect.bottom, 0.0f

我需要在DirectX 9中绘制一些东西。 我感兴趣的是将坐标调整为像素,而(0,0)将是左上角。以下是我的工作:

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)是左下角。我怎样才能改变它?
谢谢

这应该添加到代码中:

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

互换D3DXMatrixOrthoOffCenterLH中的底部和顶部:D3DXMatrixOrthoOffCenterLH(&MatorTo2D,0,clientRect.right,clientRect.bottom,0,0.0f,1.0f);