我是初学者,在iPhone上使用openGL编程和多线程,我试图编写一个小型的OpenGL游戏,我面临一个小的性能问题。
游戏将Graphics渲染为单独的openGL视图(我现在使用ES 1.1),我的渲染引擎根据用户的标题(如指南针)更新图形。在网上经历了人们的经历后,我决定:
使用委托来传达位置控制器和我的openGLViews之间的标题更新。
-(void)loadGame{
//other loading operations
[self loadThreads];
[graphicsThread start];
}
-(void)loadThreads{
//graphics thread is an ivar
graphicsThread = [[NSThread alloc] initWithTarget:self selector:@selector(loadGameViews) object:Nil];
//load other thread related stuff
}
-(void)loadGameViews{
//create and load all openGLViews
}
编辑:
-(void)loadGameViews{
//create and load all openGLViews
[self.openGLView performSelector:@selector(startAnimation) onThread:graphicsThread withObject:NULL waitUntilDone:NO];
}
代码工作正常,但我注意到fram率(在iPad上测试)下降到40 FPS(在单个线程上运行时为60)。 我想知道: