Lukas Palmer
Lukas Palmer

Reputation: 25

How fast does NSOpenGLView redraw? Does it have a default FPS?

I am creating a Cocoa application in Xcode 6, and the application uses an OpenGLView. The draw method in my extension of NSOpenGLView is getting called repeatedly, but I am not sure at which rate it is being called or a way to set the rate.

Is there a default "framerate" for NSOpenGLView, and is there a way to change it?

Upvotes: 2

Views: 512

Answers (2)

Brendan Shanks
Brendan Shanks

Reputation: 3236

Apple has a technote describing how to drive an OpenGL rendering loop. The answer is to use a CoreVideo display link (CVDisplayLink), it will call a callback during the blanking interval.

Upvotes: 2

Andon M. Coleman
Andon M. Coleman

Reputation: 43369

Generally in any window system, the window is not redrawn on a periodic schedule; it only happens in response to events that cause a "damaged" or "dirty" state.

The number of things that cause this "damaged" state has gotten a lot smaller in recent years thanks to compositing window managers (OS X uses one such window manager). It used to happen whenever a window moved over top it, but in modern window managers it only happens during/after a resize event or when the window is moved.

As you would expect, Cocoa's documentation says the same thing:

- update

Called by Cocoa when the view’s window moves or when the view itself moves or is resized.


Owen Taylor writes an excellent blog; this diagram illustrates what may happen:

  http://owtaylor.files.wordpress.com/2011/06/benchmark-method-late-damage.png?w=640&h=239

If a compositor isn’t redrawing immediately when it receives damage from a client, but is waiting a bit for more damage, then it’s possible it might wait too long and miss the vertical reblank entirely. Then the frame rate could drop way down, even if there was plenty of CPU and GPU available.

Upvotes: 1

Related Questions