Alternative of CADisplayLink for Mac OS X

前端 未结 2 1536
死守一世寂寞
死守一世寂寞 2020-12-28 17:19

Is iOS there is CADisplayLink, in Mac OS X there is CVDisplayLink, but I can\'t find a way to use it, all the examples are related to OpenGL.

I created this custom U

2条回答
  •  鱼传尺愫
    2020-12-28 18:05

    I would think that an NSTimer would be the way to go here. Your statement "it doesn't have the same accuracy", is interesting. Perhaps what you are mistaking for an accuracy problem is a run loop mode problem. If you are seeing the timer not fire when you are doing certain things such as opening menus or dragging, you may need to just change the run loop modes that the timer is running in.

    Another option is to calculate your animation based on the actual time that it's rendered, not on an assumed difference since the last render pass. Doing the latter will visually exaggerate any delays in rendering that might be otherwise go unnoticed.

    Aside from NSTimer, you can also do timers in GCD. Take a look at this example: http://www.fieryrobot.com/blog/2010/07/10/a-watchdog-timer-in-gcd/

    We use CVDisplayLink for OpenGL rendering that includes video playback. I am pretty sure it's overkill for what you are trying to do.

提交回复
热议问题