【问题标题】:Directx 11 2D orthoDirectx 11 2D 正交
【发布时间】:2017-06-16 16:05:56
【问题描述】:

我开始使用 Directx 11,但在设置相机时遇到了一些问题。 我想将原点设置在屏幕的左上角,目前它位于左下角,这就是我的设置方式:

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

这就是我想要的

这是我目前的坐标系统:

【问题讨论】:

  • 您应该避免使用旧的 D3DXMath 库。它仅在已弃用的 D3DX11 帮助程序库中受支持。见Living without D3DX

标签: c++ directx-11


【解决方案1】:

交换 y 参数以构建矩阵:

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

【讨论】:

  • 对不起,如果我这样做了,我就看不到纹理了
  • 你能给我顶点吗?另外,检查你的三角形现在没有被剔除
  • 天哪,我忘了改变顶点天哪,非常感谢你是最棒的
猜你喜欢
  • 1970-01-01
  • 2013-07-07
  • 2016-10-16
  • 2017-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-29
相关资源
最近更新 更多