I want to be able to run my game without a locked framerate (currently 60 fps). The only way that I have found to run the animation is with a NSTimer. Is there a way to have an unrestricted framerate in Cocoa. If so, a link or a code snippet would help greatly.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you really want to do this, you might need to use the CGL interface. In a valid GL context, CGLGetCurrentContext
returns an (opaque) context object. CGLSetParameter
can be used to set a value for the kCGLCPSwapInterval
parameter. A value of (0)
disables waiting for vsync.
回答2:
This enabled me to get around ~700 frames per second on my MacBook Pro
- Download Graphics Tools for Xcode - Late August 2014
- Install or just mount Graphic Tools
- Open Quartz Debug
- Go to Tools -> Show Beam Sync Tools
- Select Disable Beam Synchronization
It is not permanent either, perfect for testing/benchmarking.
Source