iosipadopengl-esopengl-es-3.0openglcontext

OpenGl ES 3.0 Context not created on iPad (works in Simulator)


I'm working on a cross platform renderer for PC (Windows, Linux, Mac) and iOS. The iOS part is currently built around OpenGL ES 2.0 and I wanted to upgrade to ES 3.0. So I replaced the following line (that works)

context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

with this line:

context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];

... and I included OpenGLES/ES3/gl.h and OpenGLES/ES3/glext.h.

In the simulator this works perfectly fine but running on the actual iPad it doesn’t work anymore and the context is nil.

I really don’t know what I’m missing here since the iPad is running the newest version of iOS (iOS 8.3) and shouldn't have problems with ES 3.0. I don’t get any errors and I can’t really debug it (“Step into” doesn’t seem to work here).


Solution

  • The features that OpenGL ES 3 adds over OpenGL ES 2 are hardware dependent, so you can create an ES3 context only on hardware that supports it. If you get back nil when creating a context, you need to fall back to rendering with OpenGL ES 2.

    The iOS hardware that supports ES3 is anything with an A7 or better GPU. That's iPad Air, iPad Air 2, iPad mini 2 & 3, iPhone 5s, 6, & 6 plus... and presumably anything that comes later.

    Note that the GPU requirement for ES3 is the same as that for Metal, so if you're going to do multiple renderers with a fallback path anyway you might want to just go all-out to get the best possible performance for those devices.

    Note also that many of the features that are part of the core OpenGL ES specification in ES3 are still available in iOS as extensions under ES2. So you can stick to ES2 and support all devices if you're just looking for, say, instancing.