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 back-buffered window
surface, then the color
buffer is copied (posted) to the native window associated with that
surface. If surface is a single-buffered
window, pixmap, or pixel buffer surface,
eglSwapBuffers has no effect.
The contents of ancillary buffers are always undefined after
calling eglSwapBuffers. The contents of the
color buffer are undefined if the value of the
EGL_SWAP_BEHAVIOR attribute of
surface is not
EGL_BUFFER_PRESERVED. The value of
EGL_SWAP_BEHAVIOR can be set for some
surfaces using
eglSurfaceAttrib.
EGL_SWAP_BEHAVIOR applies only to the color
buffer. EGL has no way to specify or query whether or not
ancillary buffers are preserved, and applications should not
rely on this behavior.
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.
Native Window Resizing
If the native window corresponding to
surface has been resized prior to the
swap, surface must be resized to match.
surface will normally be resized by the
EGL implementation at the time the native window is resized. If
the implementation cannot do this transparently to the client,
then eglSwapBuffers must detect the change
and resize surface prior to copying its pixels to the native
window. If surface shrinks as a result of
resizing, some rendered pixels are lost. If
surface grows, the newly allocated buffer
contents are undefined. The resizing behavior described here
only maintains consistency of EGL surfaces and native windows;
clients are still responsible for detecting window size changes
(using platform-specific means) and changing their viewport and
scissor regions accordingly.
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.
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,
vgFlush