OpenGL ES 2.0 相当于 glOrtho()?

发布于 2024-09-01 18:46:40 字数 186 浏览 4 评论 0原文

在我的 iPhone 应用程序中,我需要将 3D 场景投影到屏幕的 2D 坐标中以进行一些计算。我的物体经历了各种旋转、平移和缩放。所以我想我需要首先将顶点与模型视图矩阵相乘,然后我需要将其与正交投影矩阵相乘。

首先我走在正确的轨道上吗?

我有模型视图矩阵,但需要投影矩阵。 ES 2.0 中有等效的 glOrtho() 吗?

In my iphone app, I need to project 3d scene into the 2D coordinates of the screen for some calculations. My objects go through various rotations, translations and scaling. So I figured I need to multiply the vertices with ModelView matrix first, then I need to multiply it with the Orthogonal projection matrix.

First of all am on the right track?

I have the Model View Matrix, but need the projection matrix. Is there a glOrtho() equivalent in ES 2.0?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘落散花 2024-09-08 18:46:40
mat4 projectionMatrix = mat4( 2.0/768.0, 0.0, 0.0, -1.0,
                              0.0, 2.0/1024.0, 0.0, -1.0,
                              0.0, 0.0, -1.0, 0.0,
                              0.0, 0.0, 0.0, 1.0);                        

gl_Position = position;
gl_Position *= rotationMatrix;
gl_Position.x -= translateX;
gl_Position.y -= translateY;
gl_Position *= projectionMatrix;

对于固定分辨率(我的 iPad 为 1024x768),我使用了这个矩阵,一切都很顺利:)
以下是您需要在矩阵中放入哪些值的完整描述: glOrtho.html

mat4 projectionMatrix = mat4( 2.0/768.0, 0.0, 0.0, -1.0,
                              0.0, 2.0/1024.0, 0.0, -1.0,
                              0.0, 0.0, -1.0, 0.0,
                              0.0, 0.0, 0.0, 1.0);                        

gl_Position = position;
gl_Position *= rotationMatrix;
gl_Position.x -= translateX;
gl_Position.y -= translateY;
gl_Position *= projectionMatrix;

For a fixed resolution (1024x768 in my case for iPad) I used this matrix and everything works like charm :)
Here is complete description what values you need to put in your matrix: glOrtho.html

起风了 2024-09-08 18:46:40

glOrtho() 的手册页 描述了等效的操作,所以只要你手头有矩阵就应该能够重新实现它。

The manual page for glOrtho() describes the equivalent operations, so as long as you have the matrix handy should be able re-implement it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文