This is tricky, I didn't find a good way of doing it and I am sure there are better ways, but for me performance weren't a huge problem so I settled for it. I don't have a complete solution and it's not solving the problem in the way you asked for (i.e. by threading the rendering) but perhaps something that might be worth looking at at least. If I can come up with a better solution I will update it, but for now this is all I've got.
The way I did it is that I actually have a transparent ViewController "on top" of the glkViewController
, and anything that I want to interact with on top of the GLKViewController (such as tablesViews, buttons, and pretty much UI stuff) is added to that.
The way I do this is that I have a singleton object for my view controller called OverlayViewController
which I found helpful since I want to access it easily from anywhere, don't know if that would fit into your design but it made sense for me. And this is added in the GLKViewController::viewWillAppear
selector.
And that really is all the magic. So I have a overlay view which is playing host to any IOKit-type objects. I add it like this (easier to just paste my viewWillAppear:
from my GLKViewController
subclass)
- (void) viewWillAppear: (BOOL) animated {
[[[OverlayViewController shared] view] setUserInteractionEnabled:NO];
[self.parentViewController.view addSubview: [[OverlayViewController shared] view]];
...
}
this basically mean that there will be two views controllers which you see but they are "independent" of each other.
There are obvious problems with this approach however, such as the tedious work of keeping track of which view will currently accept user interaction, since they are on top of each other this isn't handled.
So with that said I am looking into if it's possible to dispatch a thread dedicated to rendering in GLKit.