问题
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
来源:https://stackoverflow.com/questions/10866561/cocoa-opengl-unlocked-framerate