我有一个动画透明的OpenGL ES子视图(Apple的模板EAGLView类的修改),它绘制一个旋转的球体.就像Apple的例子一样,CADisplayLink用在可用的设备上.
在同一屏幕上,有一个UIScrollView包含可以选择的UIButtons.当用户滚动UIScrollView时,我的EAGLView的动画会冻结.此行为在iPhone 2G设备上的iOS模拟器4.2和iPhone OS 3.1.3上重现.
除了编写自己的滚动视图之外,还有任何关于如何防止EAGLView暂停的想法?
我正在开发一个模拟器作为一个侧面/有趣的项目,但我遇到了一些性能问题,并且没有弄清楚它们来自哪里.
该应用程序主要由用于显示的GLKView和用于cpu仿真的具有无限循环的单独线程组成.这是一个示例,其中包含所有实际仿真代码,但仍然显示问题:
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
GLKView *glView = [[GLKView alloc] initWithFrame:self.view.bounds];
glView.delegate = self;
glView.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
[EAGLContext setCurrentContext:glView.context];
[self.view addSubview:glView];
glView.enableSetNeedsDisplay = NO;
CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:glView selector:@selector(display)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
dispatch_get_main_queue(), ^{
dispatch_async(dispatch_queue_create("yeah", DISPATCH_QUEUE_SERIAL), ^{
CFTimeInterval lastTime = 0;
CFTimeInterval time = 0;
int instructions = 0;
while(1) {
// here be cpu emulation
if (lastTime == 0) {
lastTime = CACurrentMediaTime();
} else {
CFTimeInterval newTime = CACurrentMediaTime();
time …Run Code Online (Sandbox Code Playgroud)