iPhone: What is the best way to use both OpenGL and the native user interface in an application?

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?

Any comments much appreciated!

10.12.2008 22:25:00
1 ОТВЕТ

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.

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.

12
11.12.2008 23:58:55