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 theNSOpenGLContext
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 toflushBuffer
.
And here go my questions:
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.
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.