<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLContext/flushBuffer()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLContext(im)flushBuffer"
  },
  "title" : "flushBuffer()"
}
-->

# flushBuffer()

Copies the back buffer to the front buffer of the OpenGL context.

```
func flushBuffer()
```

## Discussion

If the receiver is not a double-buffered context, this call does nothing.

If the [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object used to create the context had a <doc://com.apple.documentation/documentation/Swift/false> backing store attribute (`NSOpenGLPFABackingStore`), the buffers may be exchanged rather than copied. This is often the case in full-screen mode.

According to the swap interval context attribute (see [`NSOpenGLCPSwapInterval`](/documentation/AppKit/NSOpenGLCPSwapInterval)), the copy may take place during the vertical retrace of the monitor, rather than immediately after [`flushBuffer()`](/documentation/AppKit/NSOpenGLContext/flushBuffer()) is called. An implicit `glFlush` is done by [`flushBuffer()`](/documentation/AppKit/NSOpenGLContext/flushBuffer()) before it returns. For optimal performance, an application should not call `glFlush` immediately before calling [`flushBuffer()`](/documentation/AppKit/NSOpenGLContext/flushBuffer()). Subsequent OpenGL commands can be issued immediately after calling [`flushBuffer()`](/documentation/AppKit/NSOpenGLContext/flushBuffer()), but are not executed until the buffer copy is completed.

## See Also

[`func getValues(UnsafeMutablePointer<GLint>, for: NSOpenGLContext.Parameter)`](/documentation/AppKit/NSOpenGLContext/getValues(_:for:))

Returns the value of the requested parameter.

[`init?(format: NSOpenGLPixelFormat, share: NSOpenGLContext?)`](/documentation/AppKit/NSOpenGLContext/init(format:share:))

Returns an OpenGL context object initialized with the specified pixel format information.

[`func setValues(UnsafePointer<GLint>, for: NSOpenGLContext.Parameter)`](/documentation/AppKit/NSOpenGLContext/setValues(_:for:))

Sets the value of the specified parameter.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)