iOS,在单独的线程上运行openGLES会导致帧速率降低吗?

时间:2013-03-30 13:04:23

标签: ios multithreading opengl-es nsthread

我是初学者,在iPhone上使用openGL编程和多线程,我试图编写一个小型的OpenGL游戏,我面临一个小的性能问题。

游戏将Graphics渲染为单独的openGL视图(我现在使用ES 1.1),我的渲染引擎根据用户的标题(如指南针)更新图形。在网上经历了人们的经历后,我决定:

  1. 在一个单独的线程上运行所有与openGL相关的操作(线程之间没有与openGL相关的操作)。
  2. 从主线程上的位置服务运行回调
  3. 使用委托来传达位置控制器和我的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
    
    
        }
    
  4. 编辑:

     -(void)loadGameViews{
    
             //create and load all openGLViews
            [self.openGLView performSelector:@selector(startAnimation) onThread:graphicsThread withObject:NULL waitUntilDone:NO];
    
            }         
    

    代码工作正常,但我注意到fram率(在iPad上测试)下降到40 FPS(在单个线程上运行时为60)。 我想知道:

    1. 如果40 FPS是游戏的可接受帧速率。
    2. 如果我的线程逻辑是正确的(或者有更好的方法吗?)
    3. 如果有办法将帧速率提高到60 FPS

0 个答案:

没有答案