Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multithreading GLKView drawing

My main view controller contains many sub-views. One such subview is a GLKView linked up to a GLKViewController. The GLKViewController seems to be the one in charge of updating the GLKView's display, and something automagical is calling that update function on the main thread.

One of my other views in this main view controller is a UITableView. When the user is interacting with the table view, the GLKView stops updating.

I'll admit, I am pretty new to OGL ES programming, so I'm not sure how to approach this. I need to get the GLKViewController's

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect;

method to be called on a separate thread from the main thread, so I can keep the GLKView animating while the user is interacting with other elements.

like image 874
Dan F Avatar asked Nov 30 '12 21:11

Dan F


1 Answers

GLKViewController is using a CADisplayLink to call update/draw at a frequency which matches your display refresh rate. When your tableview/scrollview starts tracking a touch, the run loop starts giving it all the priority. You may have to split out your own GLKView and CADisplayLink (instead of using GLKViewController), in order to modify the run loop mode of the CADisplayLink so that it will keep going even if the tableview/scrollview is tracking touches. See this discussion for more info:

like image 131
mattorb Avatar answered Oct 09 '22 13:10

mattorb