Question

According to Apple's documentation, CGLFlushDrawable or it's Cocoa equivalent flushBuffer may behave in couple different ways. Normally for a windowed application the contents of a back buffer are copied to the visible buffer like it's stated here:

CGLFlushDrawable

Copies the back buffer of a double-buffered context to the front buffer.

I assume the contents of the drawing buffer are left untouched (see question 1.). Even if I'm wrong, it can be assured by passing the kCGLPFABackingStore attribute to CGLChoosePixelFormat.

But further reading reaveals, that under some circumstances the buffers may be swapped rather than copying being performed:

If the backing store attribute is set to false, the buffers can be exchanged rather than copied. This is often the case in full-screen mode.

And also this states

When there is no content above your full-screen window, Mac OS X automatically attempts to optimize this context’s performance. For example, when your application calls flushBuffer on the NSOpenGLContext object, the system may swap the buffers rather than copying the contents of the back buffer to the front buffer. (...) Because the system may choose to swap the buffers rather than copy them, your application must completely redraw the scene after every call to flushBuffer.

And here go my questions:

  1. If the back buffer is copied, is it guaranteed, that it's contents are preserved even without the backing store attribute?
  2. If the bufferse are swapped, does the back buffer get contents of the front buffer, or is it undefined so it could as well get random stuff?
  3. The system may choose to swap buffers, but is there any way to determine if it actually did choose to do so?
  4. In any of those cases, is there a way to determine if the buffer was preserved, exchanged with the front buffer or got messed up?

Also any information on how it is made in WGL, GLX or EGL would be appreciated. I particulary need the answer to the question 4.

Was it helpful?

Solution

  1. No, it's not guaranteed.
  2. It might be random.
  3. No, I don't believe so.
  4. No. If you don't specify kCGLPFABackingStore or NSOpenGLPFABackingStore, then you can't make any assumptions about the contents of the back buffer, which is why the docs say you must redraw from scratch for every frame.

I'm not sure what you're asking about WGL, GLX, and EGL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top