Iphone 如何修复';粘性';在我的openGLES应用程序中移动触摸屏?

Iphone 如何修复';粘性';在我的openGLES应用程序中移动触摸屏?,iphone,opengl-es,Iphone,Opengl Es,我使用分离线程方法进行openGL场景渲染 //This is at the end of my init method SEL selector = @selector(preMainLoop); NSThread *thread = [[NSThread alloc] initWithTarget:self selector:selector object:nil]; [thread start]; [thread release]; } -(void) preMainLoop {

我使用分离线程方法进行openGL场景渲染

//This is at the end of my init method
 SEL selector = @selector(preMainLoop);
 NSThread *thread = [[NSThread alloc] initWithTarget:self selector:selector object:nil];
 [thread start];
 [thread release];
}

-(void) preMainLoop
{
 while (isRunning) {

  NSAutoreleasePool *loopPool = [NSAutoreleasePool new];

  [self performSelectorOnMainThread:@selector(mainLoop) withObject:nil waitUntilDone:YES];

  [loopPool release];
 }
}
当我开始接触事件时,我想相应地更新我的场景。但场景的更新速度似乎比iPhone记录触摸事件的速度要快得多。为了进行测试,我尝试根据UITouch的当前位置在屏幕上拖动一个框(在触摸移动期间更新位置)。我还有一个独立移动的盒子,不受触摸的影响

独立框以每秒60帧的速度平滑移动。触摸框有“急促”的移动,这让我相信渲染循环正在挤出触摸事件或其他影响

感谢您的帮助

对NSTimer和MainLoop进行了长期的比较和对比讨论。特别是,我认为您正在寻找以下方面:

    //Yield to system calls (touches, etc.) for one ms.
    while( CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE) == kCFRunLoopRunHandledSource);
但是,由于您在同一个单线程上执行此操作,我个人怀疑您是否会看到与正确配置的NSTimer相比的任何性能改进,甚至可能受到影响。您的里程数可能会有所不同,但在启动之前,可能值得对这两种方法进行测试并做一些度量。这是一件很容易测试的事情