简体   繁体   English

iPhone是否有帧频限制?

[英]Is there frame rate limit on the iPhone?

I as a test, setup my opengl game's update() and render() functions in a while loop on a separate NSThread. 作为测试,我在单独的NSThread上的while循环中设置了我的opengl游戏的update()和render()函数。 It runs at exactly 60FPS. 它以60FPS的速度运行。 How is this possible? 这怎么可能? It's what I want actually, but why is it doing that? 这实际上是我想要的,但是为什么要这样做呢? I thought an NSThread would run as fast as it could...? 我以为NSThread会尽可能快地运行...? It seems V-synced. 似乎是V同步的。

 func setupGL(){
        glThread = NSThread(target: self, selector: "glRun", object: nil);
        glThread.start();
    }


 func glRun(){
        //Start and run Opengl on a separate Thread
        setupLayer();
        setupContext();
        setupRenderBuffer();
        //setupDepthBuffer();
        setupFrameBuffer();
        engine.setupEngine(GLfloat(self.frame.size.width) * GLfloat(scale), screenHeight: GLfloat(self.frame.size.height) * GLfloat(scale));
        //setupDisplayLink();
        print("THREAD STARTED!");
        while(true){
            update()
            render();
            logger.logFrame();
        }
    }

It's because the iOS reduces usage of the hardware to reasonable levels. 这是因为iOS将硬件的使用降低到合理的水平。 The truth is you do not need more than 60fps because the screen will not refresh faster, so the frame rate is limited. 事实是您不需要超过60fps,因为屏幕不会刷新得更快,因此帧速率受到限制。 In this way the battery life is significantly extended. 这样,电池寿命就大大延长了。

Your use of NSThread does not matter in this case because the limits are in the OpenGL layer. 在这种情况下,您对NSThread使用无关紧要,因为限制在OpenGL层中。

You can control frame rate by setting CADisplayLink and it's frameInterval value. 您可以通过设置CADisplayLink及其frameInterval值来控制帧速率。

Yes, there is a frame rate limit on iOS. 是的,iOS上有帧速率限制。 All iOS devices (as of this writing) refresh the screen at most 60 times per second. 所有iOS设备(截至撰写本文时)每秒最多刷新屏幕60次。 See, for example, WWDC 2015 Session 233: Advanced Touch Input on iOS , at 4m20s: 举例来说,请参阅WWDC 2015大会233:iOS上的高级触摸输入 ,时间为4时20分:

Our products refresh the screen at 60 hertz or 60 times per second. 我们的产品以60赫兹或每秒60次的速度刷新屏幕。

The iOS OpenGL ES implementation knows this, and synchronizes to the window server's screen refresh. iOS OpenGL ES实现知道这一点,并与窗口服务器的屏幕刷新同步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM