Michael
Michael

Reputation: 11

Multiple OpenGL views on Iphone?

I get how to do a 1 screen opengl view. But.... How about multiple opengl(1.1) view(s) for a game or drawing program? For example: After the drawing program starts up and someone does a 3 finger touch, it would bring up a toolkit of sorts on the top third of the screen for making drawing adjustments. Or a game that has an animated splash screen the going to the actual game. Info button and other choices done in opengl as well.

The main point being I want to do all in opengl and need to know how to do multiple opengl views.

Thanks for any advice!!

Upvotes: 1

Views: 1021

Answers (2)

Rajavanya Subramaniyan
Rajavanya Subramaniyan

Reputation: 2155

I would suggest don't use multiple views too. Instead, just set your viewport differently each time and draw with a different LookAt position.

Upvotes: 0

Brad Larson
Brad Larson

Reputation: 170309

It's not hard to implement multiple OpenGL ES rendering surfaces, you simply need to create multiple views that have CAEAGLLayers backing them.

Generally, multiple OpenGL ES layers are not recommended for performance reasons. You generally want to have one opaque fullscreen OpenGL ES layer for all of the content that needs this. Anything you can render in multiple contexts should be able to be drawn in a single one.

However, all of the things you describe can easily be done using standard UIViews and Core Animation. Overlaying UIViews on opaque OpenGL ES content only leads to a ~5% reduction in rendering framerate in my tests, which I consider perfectly acceptable. This is what I do in Molecules, and you can check out the code for that application to see how straightforward it is to layer these controls on top of OpenGL ES content.

I'd recommend going this route, because re-implementing buttons and other UI elements will take far more code in OpenGL ES than just using the native controls. You'll be sinking a lot of time into reinventing the wheel that could be used to improve other areas of your application.

Upvotes: 2

Related Questions