2

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Chase Walden
  • 1,252
  • 1
  • 14
  • 31
  • 2
    What's the point of drawing faster than the display can refresh? You're just wasting CPU cycles. If you use a `CVDisplayLink` you're guaranteed to be drawing as fast as the display will go. – Rob Keniger Jun 03 '12 at 04:50
  • @RobKeniger I'm doing this mainly to see how quickly one frame can be completed so that I can figure if I can integrate more complex and accurate calculations for things like collision detection and phong lighting. I can't really do this though because I have a locked framerate and can't tell how much more the CPU can handle per frame. – Chase Walden Jun 03 '12 at 19:41
  • 2
    @Chase: Sure you can. Just use a high precision timer to measure how much time is spent waiting for the next frame to begin. – Ben Voigt Jun 03 '12 at 22:55
  • @BenVoigt that actually makes a lot of sense. If you post that as an answer I can close this question. Thanks – Chase Walden Jun 04 '12 at 02:45

3 Answers3

8

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.

Brett Hale
  • 21,653
  • 2
  • 61
  • 90
5

This enabled me to get around ~700 frames per second on my MacBook Pro

It is not permanent either, perfect for testing/benchmarking.

Source

cevaris
  • 5,671
  • 2
  • 49
  • 34
  • This still works with 10.9? I'll have to try that. Just setting the swap interval like described in the older answer did not work anymore for me. – Reto Koradi Sep 05 '14 at 04:37
  • Go to Tools -> Show Beam Sync Tools no longer exists in the latest tools, idea? – daslicht Jan 03 '16 at 19:20
  • Hmm. Perhaps download an older/newer version of Graphic Tools? Specifically [Late August 2014](http://adcdownload.apple.com/Developer_Tools/graphics_tools_for_xcode__late_august_2014/graphicstools_late_august_2014.dmg) – cevaris Jan 03 '16 at 20:43
0

The Quartz debugger in Xcode 11 (version 4.2) moved this to:

Tools->Quartz Debug Settings->Enable Vertical Sync

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/24812414) – Rob Dec 10 '19 at 12:28
  • but it sure followed the thread above. Should I cut and paste the 5 year old answer or can we somehow add this add a comment? – william george Dec 12 '19 at 05:21