简体   繁体   中英

Directx 11 2D ortho

I startet with Directx 11 and I have some problems with setting up the camera. I want to set the origin to the top-left of the sceen, currently it is on bot-left this is how I set it up:

D3DXMatrixIdentity(&mProjection);
D3DXMatrixIdentity(&mView);

mPosition = D3DXVECTOR3{ 0.0f, 0.0f, -0.5f };
mTarget = D3DXVECTOR3{ 0.0f, 0.0f, 0.0f };
mUp = D3DXVECTOR3{ 0.0f, 0.0f, 0.0f };

D3DXMatrixOrthoOffCenterLH(&mProjection,
    0.0f, static_cast<Float32>(WindowWidth),
    0.0f, static_cast<Float32>(WindowHeight), 0.0f, 1.0f);

and here is how I want it 在此处输入图片说明

this is currently my coord system: 在此处输入图片说明

swap y parameters for building the matrix:

D3DXMatrixOrthoOffCenterLH(&mProjection,
0.0f, static_cast<Float32>(WindowWidth),
static_cast<Float32>(WindowHeight), 0.0f, 0.0f, 1.0f);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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