iPhone:在应用程序中使用OpenGL和本机用户界面的最佳方法是什么? [英] iPhone: What is the best way to use both OpenGL and the native user interface in an application?
问题描述
我对iPhone平台很陌生,所以我想知道在OpenGL渲染和UIView之间切换的最佳方法是什么?
I'm pretty new to the iPhone platform, so I'm wondering what the best way to switch between OpenGL rendering and a UIView might be?
任何评论非常感谢!
推荐答案
根本不需要切换模式。 iPhone上的OpenGL ES渲染是在CAEAGLLayer核心动画层中完成的。这可以用作UIView的基础层,这意味着您可以将所有UIView布局和触摸处理与3-D渲染相结合。这个UIView可以是全屏的,也可以放在显示器的任何位置。 UIViews也可以成为你的三维视图的子视图,因此它们可以出现在你的渲染上方。
There's no need to switch modes at all. OpenGL ES rendering on the iPhone is done in a CAEAGLLayer Core Animation layer. This can be used as the base layer for a UIView, which means that you can combine all the UIView layout and touch handling with your 3-D rendering. This UIView can be fullscreen or placed anywhere on the display. UIViews also can be made subviews of your 3-D view, therefore they can appear above your rendering.
OpenGL ES Application Xcode模板为你提供了一个UIView中的OpenGL层实例,是一个很好的起点。有关更复杂的示例,我可以引导您访问分子的源代码,我的三维分子查看器。在该应用程序中,我使用了大量的视图功能进行触摸检测,并在右下角放置一个信息按钮作为子视图。我甚至用另一个视图替换该视图,以便在进入应用程序的设置时生成翻转动画。
The OpenGL ES Application Xcode template gives you an OpenGL layer within a UIView instance and is a good place to start. For a more complex example, I can direct you to the source code for Molecules, my 3-D molecular viewer. In that application, I use a lot of the view functionality for touch detection and place an info button in the lower right as a subview. I even replace that view with another to produce a flip animation when going to the application's settings.
这篇关于iPhone:在应用程序中使用OpenGL和本机用户界面的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!