在 OpenGL ES 2.0 中在视口外绘图
我当时正在 OpenGL ES 1.1 中构建一个 2D 项目,但决定切换到 2.0,因为我只想为 iPad 进行开发。
在 1.1 中,当设置视口时,概念似乎是您仅查看完整 3D 空间的一部分,例如
CGRect rect = view.bounds;
glOrthof(-1.0, // Left
1.0, // Right
-1.0 / (rect.size.width / rect.size.height), // Bottom
1.0 / (rect.size.width / rect.size.height), // Top
0.01, // Near
10000.0); // Far
glViewport(0, 0, rect.size.width, rect.size.height);
(摘自 Jeff LaMarche 关于 OpenGL ES 的教程)
从我所看到的 2.0 的所有内容来看,没有 GlOrthof 方法来指定什么您正在查看的只是 glViewport 调用,它被描述为设置您正在其上绘制的平面。
我的目的是绘制一个可以放大和平移的 2D 线框地图。我假设要实现此目的,我将在视口内部和外部进行绘制,然后在用户平移时更改视口坐标。
如何在外部绘制 OpenGL ES 2.0 中的视口?
这是实现的正确方法吗 我想要实现什么?
我是不是误解了一切 完全吗?
感谢您对此的帮助!
I was building a 2D project in OpenGL ES 1.1 but decided to switch to 2.0 since I was only going to be developing for the iPad.
In 1.1, when a viewport is set up, the notion seems to be that you are viewing only a part of the full 3D space e.g.
CGRect rect = view.bounds;
glOrthof(-1.0, // Left
1.0, // Right
-1.0 / (rect.size.width / rect.size.height), // Bottom
1.0 / (rect.size.width / rect.size.height), // Top
0.01, // Near
10000.0); // Far
glViewport(0, 0, rect.size.width, rect.size.height);
(Taken from Jeff LaMarche's tutorial on OpenGL ES)
From everything I've seen of 2.0, there is no GlOrthof method to specify what you're looking at, only the glViewport call, which is described as setting up the plane on which you're drawing.
My intention is to draw a 2D wireframe map that you can zoom into and pan around. I assumed to achieve this I would draw inside and outside of the viewport and then change the viewport coords as the user panned around.
How do you draw outside of the
viewport in OpenGL ES 2.0?Is this the correct way of achieving
what I want to achieve?Have I misunderstood everything
entirely?
Thanks for your help with this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该使用矩阵在世界各地移动(glOrthof是将当前矩阵乘以指定参数创建的投影矩阵),在OpenGL ES 2.0中你负责在着色器中使用矩阵(主要是为了计算最终位置,你将位置乘以ModelViewProjection矩阵) ,例如,您可以拥有与屏幕平行的大 2D 平面,只需沿 Z 轴(视图矩阵)移动即可获得 ZoomIn ZoomOut 功能。
可以使用良好的资源:
powervr opengl es 2 sdk
或查看一些游戏开发人员类似 gamasutra gamedev.net
You should use matrices to move around the world ( glOrthof is multipling current matrix by projection matrix created with specified parameters ), in OpenGL ES 2.0 you are responsible for using matrices in shaders ( mainly to calculate final position, you multiply position by ModelViewProjection matrix ), for example you can have big 2D plane parallel to screen and just move along Z axis ( View matrix ) to get ZoomIn ZoomOut functionality.
Good resources are avaiable:
powervr opengl es 2 sdk
or look through some gamedev pages like gamasutra gamedev.net