c# - 左上原点的 OpenTK 正交投影
问题描述
如何设置 openTK 以便获得正交投影,其中:
- 原点在屏幕的左上角
- 我可以使用“正常”像素坐标,例如:如果我的窗口是 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
andbottom
参数:
_projectionMatrix = Matrix4.CreateOrthographicOffCenter(
ClientRectangle.X,
ClientRectangle.X + ClientRectangle.Width,
ClientRectangle.Y + ClientRectangle.Height,
ClientRectangle.Y,
-1.0f, 1.0f);
推荐阅读
- symfony - Symfony 5 Twig 3 Webpack Encore fulllCalendar 未呈现
- java - 在球衣中发布 +200MB 文件时出错
- c - 如何将结构成员作为引用传递给函数?
- python - Python 文件在 IDLE 中运行,但不是作为 EXE
- powershell - 使用 Power Shell 脚本的 Office 365 电子邮件活动用户报告
- javascript - 从 Angular 的表单组中删除特定的验证器
- webrtc - PeerJS 服务器 完全不工作?
- ruby-on-rails - ActiveRecord::StatementInvalid (PG::UndefinedTable: 错误: 关系“用户”不存在
- spring-boot - Spring Batch 动态块大小基于 CSV 中的行数,不计算标题行
- python - Arduino Client 通过 websocketsocket 连接到服务器但无法与之通信