Create the view with the
CAEAGLLayer
and create theEAGLContext
on the main threadCreate shared
EAGLContext
s to be used for background threads via the sharegroup values from the primary contextMake those shared contexts current on the background threads
Be VERY careful about using libdispatch and contexts (ideally you should use the NSThread methods for running things on the main thread) Specifically, beware the optimization documented for
dispatch_sync
.
The Apportable threading model is a bit non-standard compared to the common Android one. This is mainly due to the fact that iOS runs OpenGL in it's main thread. The thread that your application is started on is the same thread that the initial OpenGL surface is created on. The interesting ramification to this is that our Android based views are created and managed in the GL thread as well (by some clever manipulations of the Looper/MessageQueue and Dialog constructs). As long as the first OpenGL context that you reference in Objective-C is on the main thread; most things for shared contexts should work as expected. However if this is not the case things could devolve very quickly. Ideally you should create shared contexts to swap to background threads based off of the primary context created from the main thread.
More at the Apportable discussion group