多线程GLKView绘图 [英] Multithreading GLKView drawing
问题描述
我的主视图控制器包含许多子视图。一个这样的子视图是 GLKView
链接到 GLKViewController
。 GLKViewController
似乎是负责更新 GLKView
的显示器,而自动化的东西正在调用该更新主线程上的函数。
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.
此主视图控制器中的其他一个视图是 UITableView
。当用户与表视图交互时, GLKView
将停止更新。
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.
我承认,我对OGL ES编程很新,所以我不知道如何解决这个问题。我需要得到 GLKViewController
's
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;
在主线程的单独线程上调用的方法,所以我可以保留<$ c当用户与其他元素交互时,$ c> GLKView 动画。
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.
推荐答案
GLKViewController正在使用CADisplayLink以与您的显示刷新率匹配的频率调用更新/绘制。当您的tableview / scrollview开始跟踪触摸时,运行循环开始为其提供所有优先级。您可能必须拆分自己的GLKView和CADisplayLink(而不是使用GLKViewController),以便修改CADisplayLink的运行循环模式,以便即使tableview / scrollview跟踪触摸它也会继续运行。请参阅此讨论更多信息:
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:
这篇关于多线程GLKView绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!