具有左上原点的 OpenTK 正交投影
OpenTK orthographic projection with left top origin
如何设置 openTK 以便获得正交投影,其中:
- 原点在屏幕的左上角
- 我可以使用 "normal" 像素坐标,例如:如果我的 window 是 500 X 400 那么:
- 0,0是左上角
- 500,0是右上角
- 右下角是500,400
- 0,400是左下角
我目前有这个:
_projectionMatrix = Matrix4.CreateOrthographicOffCenter(
ClientRectangle.X, ClientRectangle.Width,
ClientRectangle.Y, ClientRectangle.Height, -1.0f, 1.0f);
我不能完全理解发生了什么,但似乎原点现在在左下角,我也不知道坐标是否与屏幕上的像素匹配。
Matrix4.CreateOrthographicOffCenter
的参数是 left
、right
、bottom
、top
、near
和 far
的长方体视图体积。
如果视图原点 (ClientRectangle.Y
) 必须位于顶部,则必须交换 top
和 bottom
参数:
_projectionMatrix = Matrix4.CreateOrthographicOffCenter(
ClientRectangle.X,
ClientRectangle.X + ClientRectangle.Width,
ClientRectangle.Y + ClientRectangle.Height,
ClientRectangle.Y,
-1.0f, 1.0f);
如何设置 openTK 以便获得正交投影,其中:
- 原点在屏幕的左上角
- 我可以使用 "normal" 像素坐标,例如:如果我的 window 是 500 X 400 那么:
- 0,0是左上角
- 500,0是右上角
- 右下角是500,400
- 0,400是左下角
我目前有这个:
_projectionMatrix = Matrix4.CreateOrthographicOffCenter(
ClientRectangle.X, ClientRectangle.Width,
ClientRectangle.Y, ClientRectangle.Height, -1.0f, 1.0f);
我不能完全理解发生了什么,但似乎原点现在在左下角,我也不知道坐标是否与屏幕上的像素匹配。
Matrix4.CreateOrthographicOffCenter
的参数是 left
、right
、bottom
、top
、near
和 far
的长方体视图体积。
如果视图原点 (ClientRectangle.Y
) 必须位于顶部,则必须交换 top
和 bottom
参数:
_projectionMatrix = Matrix4.CreateOrthographicOffCenter(
ClientRectangle.X,
ClientRectangle.X + ClientRectangle.Width,
ClientRectangle.Y + ClientRectangle.Height,
ClientRectangle.Y,
-1.0f, 1.0f);