2003-2014 The Khronos Group Inc.
eglSwapBuffers 3G
eglSwapBuffers post EGL surface color buffer to a native window

## C Specification

EGLBoolean `eglSwapBuffers` EGLDisplay display EGLSurface surface

## Parameters

display

  Specifies the EGL display connection.

surface

  Specifies the EGL drawing surface whose buffers are to be swapped.

## Description

If surface is a window surface, `eglSwapBuffers` posts its color buffer to the associated native window.

The contents of ancillary buffers are always undefined after calling `eglSwapBuffers`. The contents of the color buffer are left unchanged if the value of the `EGL_SWAP_BEHAVIOR` attribute of surface is `EGL_BUFFER_PRESERVED`, and are undefined if the value is `EGL_BUFFER_DESTROYED`. The value of `EGL_SWAP_BEHAVIOR` can be set for some surfaces using eglSurfaceAttrib.

`eglSwapBuffers` performs an implicit flush operation on the context (`glFlush` for an OpenGL ES or OpenGL context, `vgFlush` for an OpenVG context) bound to surface before swapping. Subsequent client API commands may be issued on that context immediately after calling `eglSwapBuffers`, but are not executed until the buffer exchange is completed.

If surface is a pixel buffer or a pixmap, `eglSwapBuffers` has no effect, and no error is generated.

## Notes

Attribute `EGL_SWAP_BEHAVIOR` is supported only if the EGL version is 1.2 or greater. In earlier versions, behavior is as though the attribute exists, and always has the value `EGL_BUFFER_DESTROYED`.

The EGL 1.4 specification was updated to acknowledge that ancillary buffers are not necessarily preserved after a swap, and that the `EGL_SWAP_BEHAVIOR` attribute applies only to the color buffer. This change in the specification acknowledged the behavior of many shipping implementations, and is not intended to result in behavior changes in any existing implementation. Applications which require preservation of ancillary buffers across a swap should be aware that not all implementations can preserve them, and that EGL 1.4 has no way to query whether or not they are preserved.

## Errors

`EGL_FALSE` is returned if swapping of the surface buffers fails, `EGL_TRUE` otherwise.

`EGL_BAD_DISPLAY` is generated if display is not an EGL display connection.

`EGL_NOT_INITIALIZED` is generated if display has not been initialized.

`EGL_BAD_SURFACE` is generated if surface is not an EGL drawing surface.

`EGL_CONTEXT_LOST` is generated if a power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering.

## See Also

glFlush, eglCopyBuffers

##