iOS - 使用 openGL ES 仅缩放部分显示
我正在开发一个关卡构建器应用程序来构建游戏内容。 iPad 屏幕的一部分是专用控制面板,其余部分是正在构建的关卡的图形表示。我需要在不影响控制面板的情况下放大和缩小关卡区域。我使用 openGL ES 进行渲染。有人可以在这里给我一些指示吗?我可以用不同的视口分割屏幕,然后只缩放一个吗?
I'm working on a level builder app to build content for a game. Part of the iPad screen is a dedicated control panel, while the rest is a graphical representation of the level being built. I need to zoom the level area in and out without affecting the control panel. I'm using openGL ES for rendering. Can anyone give me some pointers here? Can I split the screen with different viewports and so just scale one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
诀窍是要理解 OpenGL 是一个状态机,不存在“全局初始化”之类的东西。只要您遵循写得不好的教程,并在窗口调整大小处理程序中设置投影矩阵,您就会陷入困境。您实际要做的事情是这样的:
重要的部分是,在渲染该子部分之前,您在绘图处理程序中设置视口/剪刀和投影。
The trick is to understand that OpenGL is a state machine and there is no such thing like "global initialization". As long as you follow the badly written tutorials and have your projection matrix setup in the window resize handler you'll be stuck. What you actually do is something like this:
The important part is, that you set the viewport/scissor and the projection within the drawing handler prior to rendering that sub-part.
如果您使用 OpenGL ES(大概是 2.0)进行渲染,那么您可以完全控制渲染内容的缩放。您决定在何处应用比例,并决定如何渲染事物。
我猜你的代码目前看起来有点像这样。
当它应该看起来像这样的时候。
用于转换关卡的矩阵(或您拥有的任何转换内容)不应该用于转换控制面板。
If you're rendering with OpenGL ES (presumably 2.0), then you have full control over the scaling of what you render. You decide where the scale gets applied, and you decide how things are rendered.
I'd guess your code currently looks a bit like this.
When it should look like this.
The matrices (or whatever transformation stuff you have) you use for transforming the level should not be used for transforming the control panel.