blob: 0cdd0a11ff91917237f5b142f524cfa7b5dc0a7c [file] [log] [blame]
<refentry xmlns="" version="5.0" xml:base="" xml:id="eglIntro">
<holder>The Khronos Group Inc.</holder>
introduction to managing client API rendering through the
<acronym>EGL</acronym> API.
<refsect1 xml:id="overview"><title>Overview</title>
The <firstterm>Khronos Native Platform Graphics
Interface</firstterm> (EGL) provides a means for rendering
using a <firstterm>client API</firstterm> such as OpenGL ES
(a 3D renderer for embedded systems), OpenGL (a functional
superset of OpenGL ES for desktop systems), and OpenVG (a 2D
vector graphics renderer) together with a
<firstterm>platform</firstterm>, such as Microsoft Windows or
the X Window System.
Depending on its implementation EGL might be more or less
tightly integrated into the platform. Most EGL
functions require an EGL display connection, which can be
obtained by calling
To initialize and
query what EGL version is supported on the display
connection, call
The EGL specification does not define the set of platforms that
may be supported by an EGL implementation, nor does it specify
behavior specific to any platform. The set of supported
platforms and their behavior is defined by platform-specific
extensions. To detect if a particular platform is supported,
clients should query the <constant>EGL_EXTENSIONS</constant>
string of <constant>EGL_NO_DISPLAY</constant> using
Platforms supporting EGL make a subset of their
visuals (which may also referred to as pixel formats, frame
buffer configurations, or other similar terms) available for
client API rendering. Windows and pixmaps created with these
visuals may also be rendered into using the platform APIs.
An EGL <firstterm>surface</firstterm> extends a native
window or pixmap with additional <firstterm>auxillary
buffers</firstterm>. These buffers include a color buffer, a
depth buffer, a stencil buffer, and an alpha mask buffer.
Some or all of the buffers listed are included in each EGL
frame buffer configuration.
EGL supports rendering into three types of surfaces:
windows, pixmaps and pixel buffers (pbuffers). EGL window
and pixmap surfaces are associated with corresponding
resources of the platform. EGL pixel buffers are
EGL-only resources, and do not accept rendering through the
platform APIs.
To render using a client API into an EGL surface, you must
determine the appropriate EGL frame buffer configuration,
which supports the rendering features the application
returns an <type>EGLConfig</type> matching the required
attributes, if any. A complete list of EGL frame buffer
configurations can be obtained by calling
Attributes of a particular EGL frame buffer configuration
can be queried by calling
For EGL window and pixmap surfaces, a suitable native window
or pixmap with a matching native visual must be created
first. For a given EGL frame buffer configuration, the
native visual type and ID can be retrieved with a call to
For pixel buffers, no underlying native resource is
To create an EGL window surface from a native window, call
To create an EGL pixmap surface from a native pixmap, call
To create a pixel buffer (pbuffer) surface (which has no
associated native buffer), call
To create a pixel buffer (pbuffer) surface whose color
buffer is provided by an OpenVG <type>VGImage</type>, call
to release previously allocated resources.
An EGL rendering context is required to bind client API
rendering to an EGL surface. An EGL surface and an EGL
rendering context must have compatible EGL frame buffer
configurations. To create an EGL rendering context, call
The type of client API context created (OpenGL ES, OpenVG,
etc.) can be changed by first calling
An EGL rendering context may be bound to one or two EGL
surfaces by calling
This context/surface(s) association specifies the
<firstterm>current context</firstterm> and
<firstterm>current surface</firstterm>, and is used by all
client API rendering commands for the bound context until
is called with different arguments.
Both platform and client API commands may be used to operate
on certain surfaces. However, the two command streams are
not synchronized. Synchronization can be explicitly
specified using by calling
and possibly by calling other platform APIs.
<refsect1 xml:id="examples"><title>Examples</title>
Below is a minimal example of creating an RGBA-format window that
allows rendering with OpenGL ES.
The window is cleared to yellow when the program runs. For simplicity,
the program does not check for any errors.
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;EGL/egl.h&gt;
#include &lt;GLES/gl.h&gt;
typedef ... NativeWindowType;
extern NativeWindowType createNativeWindow(void);
static EGLint const attribute_list[] = {
int main(int argc, char ** argv)
EGLDisplay display;
EGLConfig config;
EGLContext context;
EGLSurface surface;
NativeWindowType native_window;
EGLint num_config;
/* get an EGL display connection */
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
/* initialize the EGL display connection */
eglInitialize(display, NULL, NULL);
/* get an appropriate EGL frame buffer configuration */
eglChooseConfig(display, attribute_list, &amp;config, 1, &amp;num_config);
/* create an EGL rendering context */
context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);
/* create a native window */
native_window = createNativeWindow();
/* create an EGL window surface */
surface = eglCreateWindowSurface(display, config, native_window, NULL);
/* connect the context to the surface */
eglMakeCurrent(display, surface, surface, context);
/* clear the color buffer */
glClearColor(1.0, 1.0, 0.0, 1.0);
eglSwapBuffers(display, surface);
<refsect1 xml:id="notes"><title>Notes</title>
Prior to EGL 1.5, platforms were referred to as the
<firstterm>native window system</firstterm>, and
platform-specific queries and APIs were not available. Only a
single native window system was supported.
<refsect1 xml:id="usingeglextensions"><title>Using EGL Extensions</title>
All supported EGL extensions will have a corresponding definition in
<filename>egl.h</filename> and a token in the extension strings returned
<refsect1 xml:id="futureeglversions"><title>Future EGL Versions</title>
can be used to determine at run-time what version of EGL is available.
To check the EGL version at compile-time, test whether
is defined, where <replaceable>x</replaceable> and
<replaceable>y</replaceable> are the major and minor version
<refsect1 xml:id="files"><title>Files</title>
EGL header file
<refsect1 xml:id="seealso"><title>See Also</title>
<xi:include xmlns:xi="" href="copyright.xml"/>