Opengl Es Native Platform Graphics Interface (Version 1.0) : Editor: Jon Leech
Opengl Es Native Platform Graphics Interface (Version 1.0) : Editor: Jon Leech
1 Overview 1
2 EGL Operation 2
2.1 Native Window System and Rendering APIs . . . . . . . . . . . . 2
2.1.1 Scalar Types . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.2 Displays . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Rendering Contexts and Drawing Surfaces . . . . . . . . . . . . . 3
2.2.1 Using Rendering Contexts . . . . . . . . . . . . . . . . . 4
2.2.2 Rendering Models . . . . . . . . . . . . . . . . . . . . . 4
2.2.3 Interaction With Native Rendering . . . . . . . . . . . . . 4
2.3 Direct Rendering and Address Spaces . . . . . . . . . . . . . . . 5
2.4 Shared State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4.1 Texture Objects . . . . . . . . . . . . . . . . . . . . . . . 6
2.5 Multiple Threads . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6 Power Management . . . . . . . . . . . . . . . . . . . . . . . . . 7
i
ii CONTENTS
4 Extending EGL 31
6 Glossary 33
A Version 1.0 35
A.1 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . 35
iii
Chapter 1
Overview
This document describes EGL, the interface between OpenGL ES and the underly-
ing native platform window system. It refers to concepts discussed in the OpenGL
ES specification, and may be viewed as an appendix to that document. EGL uses
OpenGL ES conventions for naming entry points and macros.
EGL provides mechanisms for creating rendering surfaces onto which OpenGL
ES can draw, and synchronizing drawing by both OpenGL ES and native platform
rendering APIs. EGL does not explicitly support remote or indirect rendering,
unlike the similar GLX API.
1
Chapter 2
EGL Operation
2
2.2. RENDERING CONTEXTS AND DRAWING SURFACES 3
2.1.2 Displays
Most EGL calls include an EGLDisplay parameter. This represents the abstract
display on which graphics are drawn. In most environments a display corresponds
to a single physical screen. The initialization routines described in section 3.2
include a method for querying a default display, and platform-specific EGL exten-
sions may be defined to obtain other displays.
• were created with respect to the same EGLDisplay (in environments sup-
porting multiple displays).
As long as the compatibility constraint and the address space requirement are
satisfied, clients can render into the same EGLSurface using different render-
ing contexts. It is also possible to use a single context to render into multiple
EGLSurfaces.
Window Resizing
EGL window surfaces need to be resized when their corresponding native window
is resized. Implementations typically use hooks into the OS and native window
system to perform this resizing on demand, transparently to the client. Some imple-
mentations may instead define an EGL extension giving explicit control of surface
resizing.
Implementations which cannot resize EGL window surfaces on demand must
instead respond to native window size changes in eglSwapBuffers (see sec-
tion 3.8.3).
used when mixing native and OpenGL ES rendering is desirable, since there is no
need to move data between the back buffer visible to OpenGL ES and the native
pixmap visible to native rendering APIs. However, pixmap surfaces may, for the
same reason, have restricted capabilities and performance relative to window and
pbuffer surfaces.
Native rendering will not be supported by pbuffer surfaces, since the color
buffers of pbuffers are allocated internally by EGL and are not accessible through
any other means.
Native rendering may be supported by window surfaces, but only if the native
window system has a compatible rendering model allowing it to share the OpenGL
ES back buffer.
When both native rendering APIs and OpenGL ES are drawing into the same
underlying surface, no guarantees are placed on the relative order of completion
of operations in the different rendering streams other than those provided by the
synchronization primitives discussed in section 3.7.
Some state is shared between OpenGL ES and the underlying native window
system and rendering APIs, including pixel values in the visible frame buffer and,
in the case of pixmaps, color buffer values.
rendering contexts to share such state rather than replicating it in each context.
EGL provides for sharing certain types of server state among contexts exist-
ing in a single address space. At present such state includes only texture objects;
additional types of state may be shared in future revisions of OpenGL ES where
such types of state (for example, display lists) are defined and where such sharing
makes sense.
3.1 Errors
Where possible, when an EGL function fails it has no side effects.
EGL functions usually return an indicator of success or failure; either an
EGLBoolean EGL TRUE or EGL FALSE value, or in the form of an out-of-band
return value indicating failure, such as returning EGL NO CONTEXT instead of a re-
quested context handle Additional information about the success or failure of the
most recent EGL function called in a specific thread, in the form of an error code,
can be obtained by calling
EGLint eglGetError();
The error codes that may be returned from eglGetError, and their meanings,
are:
EGL SUCCESS
Function succeeded.
8
3.1. ERRORS 9
Some specific error codes that may be generated by a failed EGL func-
tion, and their meanings, are described together with each function. However,
not all possible errors are described with each function. Errors whose mean-
ings are identical across many functions (such as returning EGL BAD DISPLAY or
EGL NOT INITIALIZED for an unsuitable EGLDisplay argument) may not be
described repeatedly.
EGL normally checks the validity of objects passed into it, but detecting invalid
native objects (pixmaps, windows, and displays) may not always be possible. Spec-
ifying such invalid handles may result in undefined behavior, although implemen-
tations should generate EGL BAD NATIVE PIXMAP and EGL BAD NATIVE WINDOW
errors if possible.
3.2 Initialization
Initialization must be performed once for each display prior to calling most other
EGL functions. A display can be obtained by calling
EGLDisplay eglGetDisplay(NativeDisplayType
display id);
EGL TRUE is returned on success, and major and minor are updated with the major
and minor version numbers of the EGL implementation. major and minor are not
updated if they are specified as NULL.
EGL FALSE is returned on failure and major and minor are not updated. An
EGL BAD DISPLAY error is generated if the dpy argument does not refer to a valid
EGLDisplay. An EGL NOT INITIALIZED error is generated if EGL cannot be
initialized for an otherwise valid dpy.
Initializing an already-initialized display is allowed, but the only effect of such
a call is to return EGL TRUE and update the EGL version numbers. An initialized
display may be used from other threads in the same address space without being
initalized again in those threads.
To release resources associated with use of EGL and OpenGL ES on a display,
call
Termination marks all EGL-specific resources associated with the specified display
for deletion. If contexts or surfaces created with respect to dpy are current (see
section 3.6.3) to any thread, then they are not actually released while they remain
current. Such contexts and surfaces will be destroyed, and all future references to
them will become invalid, as soon as any otherwise valid eglMakeCurrent call is
made from the thread they are bound to.
eglTerminate returns EGL TRUE on success.
If the dpy argument does not refer to a valid EGLDisplay, EGL FALSE is
returned, and an EGL BAD DISPLAY error is generated.
Termination of a display that has already been terminated, or has not yet been
initialized, is allowed, but the only effect of such a call is to return EGL TRUE, since
there are no EGL resources associated with the display to release. A terminated
display may be re-initialized by calling eglInitialize again. When re-initializing
a terminated display, resources which were marked for deletion as a result of the
earlier termination remain so marked, and references to them are not valid.
Both the major and minor portions of the version number are of arbitrary length.
The vendor-specific information is optional; if present, its format and contents are
implementation specific.
On failure, NULL is returned. An EGL NOT INITIALIZED error is generated if
EGL is not initialized for dpy. An EGL BAD PARAMETER error is generated if name
is not one of the values described above.
maximum height. The value for EGL MAX PBUFFER PIXELS is static and as-
sumes that no other pbuffers or native resources are contending for the framebuffer
memory. Thus it may not be possible to allocate a pbuffer of the size given by
EGL MAX PBUFFER PIXELS.
to get the list of all EGLConfigs that are available on the specified display. configs
is a pointer to a buffer containing config size elements. On success, EGL TRUE is
returned. The number of configurations is returned in num config, and elements 0
through num conf ig − 1 of configs are filled in with the valid EGLConfigs. No
more than config size EGLConfigs will be returned even if more are available on
the specified display. However, if eglGetConfigs is called with configs = NULL,
then no configurations are returned, but the total number of configurations available
will be returned in num config.
On failure, EGL FALSE is returned. An EGL NOT INITIALIZED error is gen-
erated if EGL is not initialized on dpy. An EGL BAD PARAMETER error is generated
if num config is NULL.
Use
to get EGLConfigs that match a list of attributes. The return value and the mean-
ing of configs, config size, and num config are the same as for eglGetConfigs.
However, only configurations matching attrib list, as discussed below, will be re-
turned.
On failure, EGL FALSE is returned. An EGL BAD ATTRIBUTE error is gener-
ated if attrib list contains an undefined EGL attribute or an attribute value that is
unrecognized or out of range.
All attribute names in attrib list are immediately followed by the corresponding
desired value. The list is terminated with EGL NONE. If an attribute is not specified
in attrib list, then the default value (listed in Table 3.3) is used (it is said to be
specified implicitly). If EGL DONT CARE is specified as an attribute value, then the
attribute will not be checked. EGL DONT CARE may be specified for all attributes
except EGL LEVEL. If attrib list is NULL or empty (first attribute is EGL NONE),
then selection and sorting of EGLConfigs is done according to the default criteria
in Tables 3.3 and 3.1, as described below under Selection and Sorting.
Selection of EGLConfigs
Smaller EGLConfigs with an attribute value that meets or exceeds the specified
value are matched.
Larger EGLConfigs with an attribute value that meets or exceeds the specified
value are matched.
Exact EGLConfigs whose attribute value equals the requested value are
matched.
Mask EGLConfigs for which the set bits of attribute include all the bits that are
set in the requested value are matched. (Additional bits might be set in the
attribute).
Some of the attributes must match the specified value exactly; others, such as
EGL RED SIZE, must meet or exceed the specified minimum values.
To retrieve an EGLConfig given its unique integer ID, use the
EGL CONFIG ID attribute. When EGL CONFIG ID is specified, all other attributes
are ignored, and only the EGLConfig with the given ID is returned.
If EGL MAX PBUFFER WIDTH, EGL MAX PBUFFER HEIGHT,
EGL MAX PBUFFER PIXELS, or EGL NATIVE VISUAL ID are specified in
attrib list, then they are ignored (however, if present, these attributes must still be
followed by an attribute value in attrib list). If EGL SURFACE TYPE is specified
in attrib list and the mask that follows does not have EGL WINDOW BIT set, or if
there are no native visual types, then the EGL NATIVE VISUAL TYPE attribute is
ignored.
If EGL TRANSPARENT TYPE is set to EGL NONE in attrib list, then
the EGL TRANSPARENT RED VALUE, EGL TRANSPARENT GREEN VALUE, and
EGL TRANSPARENT BLUE VALUE attributes are ignored.
1
The distinction between Smaller and Larger, which affects only sorting, not selection, has
proven confusing. We will update table 3.3 with separate selection criteria and sort order columns in
the next EGL revision.
Table 3.3: Default values and match criteria for EGLConfig attributes.
If no EGLConfig matching the attribute list exists, then the call succeeds, but
num config is set to 0.
Sorting of EGLConfigs
2. Larger total number of RGBA color bits (EGL RED SIZE, EGL GREEN SIZE,
EGL BLUE SIZE, plus EGL ALPHA SIZE). If the requested number of bits in
attrib list for a particular color component is 0 or EGL DONT CARE, then the
number of bits for that component is not considered.
9. Smaller EGL CONFIG ID (this is always the last sorting rule, and guarantees
a unique ordering).
If eglGetConfigAttrib succeeds then it returns EGL TRUE and the value for the
specified attribute is returned in value. Otherwise it returns EGL FALSE. If attribute
is not a valid attribute then EGL BAD ATTRIBUTE is generated.
Refer to Table 3.1 and Table 3.3 for a list of valid EGL attributes.
2. Pbuffers are EGL resources and have no associated native window or native
window type. It may not be possible to render to pbuffers using APIs other
than OpenGL ES and EGL.
The resulting pbuffer will contain color buffers and ancillary buffers as speci-
fied by config.
On failure eglCreatePbufferSurface returns EGL NO SURFACE. If the pbuffer
could not be created due to insufficient resources, then an EGL BAD ALLOC error is
generated. If config is not a valid EGLConfig, an EGL BAD CONFIG error is gen-
erated. If config does not support pbuffers, an EGL BAD MATCH error is generated.
All resources associated with surface are marked for deletion as soon as possible.
If surface is current to any thread (see section 3.6.3), resources are not actually
released while the surface remains current. Future references to surface remain
valid only so long as it is current; it will be destroyed, and all future references to it
will become invalid, as soon as any otherwise valid eglMakeCurrent call is made
from the thread it is bound to.
eglDestroySurface returns EGL FALSE on failure. An EGL BAD SURFACE er-
ror is generated if surface is not a valid rendering surface.
window surface will eventually be resized by the implementation to match (as dis-
cussed in section 3.8.1). If there is a discrepancy because EGL has not yet resized
the window surface, the size returned by eglQuerySurface will always be that of
the EGL surface, not the corresponding native window.
For a pbuffer, they will be the actual allocated size of the pbuffer (which may
be less than the requested size if EGL LARGEST PBUFFER is EGL TRUE).
eglQuerySurface returns EGL FALSE on failure and value is not updated. If
attribute is not a valid EGL surface attribute, then an EGL BAD ATTRIBUTE error
is generated. If surface is not a valid EGLSurface then an EGL BAD SURFACE
error is generated.
device driver and the other with a software renderer), then an EGL BAD MATCH er-
ror is generated. If the server does not have enough resources to allocate the new
context, then an EGL BAD ALLOC error is generated.
All resources associated with ctx are marked for deletion as soon as possible. If ctx
is current to any thread (see section 3.6.3), resources are not actually released while
the context remains current. Future references to ctx remain valid only so long as
it is current; it will be destroyed, and all future references to it will become invalid,
as soon as any otherwise valid eglMakeCurrent call is made from the thread it is
bound to).
eglDestroyContext returns EGL FALSE on failure. An EGL BAD CONTEXT er-
ror is generated if ctx is not a valid rendering context.
eglMakeCurrent binds ctx to the current rendering thread and to the draw and
read surfaces. draw is used for all OpenGL ES operations except for any pixel data
read back, which is taken from the frame buffer values of read. Note that the same
EGLSurface may be specified for both draw and read.
If the calling thread already has a current rendering context, then that context
is flushed and marked as no longer current. ctx is made the current context for the
calling thread.
eglMakeCurrent returns EGL FALSE on failure. If draw or read are not com-
patible with ctx, then an EGL BAD MATCH error is generated. If ctx is current to
some other thread, or if either draw or read are bound to contexts in another
thread, an EGL BAD ACCESS error is generated. If ctx is not a valid EGL rendering
context, an EGL BAD CONTEXT error is generated. If either draw or read are not
valid EGL surfaces, an EGL BAD SURFACE error is generated. If a native window
underlying either draw or read is no longer valid, an EGL BAD NATIVE WINDOW
error is generated. If draw and read cannot fit into graphics memory simultane-
ously, an EGL BAD MATCH error is generated. If the previous context of the calling
thread has unflushed commands, and the previous surface is no longer valid, an
EGL BAD CURRENT SURFACE error is generated. If the ancillary buffers for draw
and read cannot be allocated, an EGL BAD ALLOC error will be generated.
Other errors may arise when the context state is inconsistent with the surface
state, as described in the following paragraphs.
If draw is destroyed after eglMakeCurrent is called, then subsequent render-
ing commands will be processed and the context state will be updated, but the
frame buffer state becomes undefined. If read is destroyed after eglMakeCurrent
then pixel values read from the framebuffer (e.g., as result of calling glReadPixels)
are undefined. If a native window or pixmap underlying the draw or read surfaces
is destroyed, rendering and readback are handled as above.
To release the current context without assigning a new one, set ctx
to EGL NO CONTEXT and set draw and read to EGL NO SURFACE. If ctx is
EGL NO CONTEXT and draw and read are not EGL NO SURFACE, or if draw
or read are set to EGL NO SURFACE and ctx is not EGL NO CONTEXT, then an
EGL BAD MATCH error will be generated.
The first time ctx is made current, the viewport and scissor dimensions are set
to the size of the draw surface (as though glViewport(0, 0, w, h) and glScissor(0,
0, w, h) were called, where w and h are the width and height of the surface, respec-
tively). However, the viewport and scissor dimensions are not modified when ctx
is subsequently made current. The client is responsible for resetting the viewport
and scissor in this case.
Only one rendering context may be in use, or current, for a particular thread at
a given time, and only one context may be bound to a particular surface at a given
time.
The minimum number of current rendering contexts that must be supported by
an EGL implementation is one.
To get the current context, call
EGLContext eglGetCurrentContext(void);
readdraw is either EGL READ or EGL DRAW to respectively return the read or draw
surfaces. If there is no correponding surface, EGL NO SURFACE is returned (this is
not an error) If readdraw is neither EGL READ nor EGL DRAW, EGL NO SURFACE is
returned and an EGL BAD PARAMETER error is generated.
To get the display associated with the current context, call
EGLDisplay eglGetCurrentDisplay(void);
eglQueryContext returns in value the value of attribute for ctx. attribute must be
set to EGL CONFIG ID.
Querying EGL CONFIG ID returns the ID of the EGLConfig with respect to
which the context was created.
eglQueryContext returns EGL FALSE on failure and value is not updated. If
attribute is not a valid EGL context attribute, then an EGL BAD ATTRIBUTE error
is generated. If ctx is invalid, an EGL BAD CONTEXT error is generated.
EGLBoolean eglWaitGL(void);
Native rendering calls made with the specified marking engine, and which affect
the surface associated with the calling thread’s current context, are guaranteed to
be executed before OpenGL ES rendering calls made after eglWaitNative. The
same result may be (but is not necessarily) achievable using native synchronization
calls.
engine denotes a particular marking engine (another drawing API, such as GDI,
Xlib) to be waited on. Valid values of engine are defined by EGL extensions spe-
cific to implementations, but implementations will always recognize the symbolic
constant EGL CORE NATIVE ENGINE, which denotes the most commonly used
marking engine other then OpenGL ES itself.
eglWaitNative returns EGL TRUE on success. If there is no current rendering
context, the function has no effect but still returns EGL TRUE. If the surface does
not support native rendering (e.g. pbuffer and in most cases window surfaces), the
function has no effect but still returns EGL TRUE. If the surface associated with
the calling thread’s current context is no longer valid, EGL FALSE is returned and
an EGL BAD CURRENT SURFACE error is generated. If engine does not denote a
recognized marking engine, EGL FALSE is returned and an EGL BAD PARAMETER
error is generated.
If surface is a window surface, then the color buffer is copied to the native
window associated with that surface. If surface is a pixmap or pbuffer surface,
eglSwapBuffers has no effect.
The color buffer of surface is left in an undefined state after calling eglSwap-
Buffers.
The color buffer is copied to the specified target, which must be a valid native
pixmap handle.
The target pixmap should have the same number of components and component
sizes as the color buffer it’s being copied from. Implementations may choose to
relax this restriction by converting data to the native pixmap formats. If they do
so, they should define an EGL extension specifying which pixmap formats are
supported, and specifying the conversion arithmetic used.
The mapping of pixels in the color buffer to pixels in the pixmap is platform-
dependent, since the native platform pixel coordinate system may differ from that
of OpenGL ES .
The color buffer of surface is left unchanged after calling eglCopyBuffers.
returns the address of the extension function named by procName. procName must
be a NULL-terminated string. The pointer returned should be cast to a function
pointer type matching the extension function’s definition in that extension specifi-
cation. A return value of NULL indicates that the specified function does not exist
for the implementation.
A non-NULL return value for eglGetProcAddress does not guarantee that
an extension function is actually supported at runtime. The client must also
query glGetString(GL EXTENSIONS) (for OpenGL ES extensions) or eglQueryS-
tring(dpy, EGL EXTENSIONS) (for EGL extensions) to determine if an extension
is supported by a particular context.
Function pointers returned by eglGetProcAddress are independent of the dis-
play and the currently bound context, and may be used by any context which sup-
ports the extension.
eglGetProcAddress may be queried for all of the following functions:
Extending EGL
EGL implementors may extend EGL by adding new commands or additional enu-
merated values for existing EGL commands.
New names for EGL functions and enumerated types must clearly indicate
whether some particular feature is in the core EGL or is vendor specific. To make
a vendor-specific name, append a company identifier (in upper case) and any ad-
ditional vendor-specific tags (e.g. machine names). For instance, SGI might add
new commands and manifest constants of the form eglNewCommandSGI and
EGL NEW DEFINITION SGI. If two or more vendors agree in good faith to im-
plement the same extension, and to make the specification of that extension pub-
licly available, the procedures and tokens that are defined by the extension can be
suffixed by EXT. Extensions approved by supra-vendor organizations such as the
Khronos SIG and the OpenGL ARB use similar identifiers (OML and OES for
Khronos, and ARB for the ARB).
It is critically important for interoperability that enumerants and entry point
names be unique across vendors. The OpenGL ARB Secretary maintains a reg-
istry of enumerants, and all shipping enumerant values must be determined by
requesting blocks of enumerants from the registry. See
http://oss.sgi.com/projects/ogl-sample/registry/
31
Chapter 5
Each version of EGL supports a specified OpenGL ES version, and all prior ver-
sions of OpenGL ES up to that version. EGL 1.0 supports OpenGL ES 1.0, includ-
ing both Common and Common-Lite profiles.
http://www.khronos.org/
32
Chapter 6
Glossary
Address Space the set of objects or memory locations accessible through a single
name space. In other words, it is a data region that one or more processes
may share through pointers.
Connection a bidirectional byte stream that carries the X (and EGL) protocol be-
tween the client and the server. A client typically has only one connection to
a server.
33
34 CHAPTER 6. GLOSSARY
Thread one of a group of processes all sharing the same address space. Typically,
each thread will have its own program counter and stack pointer, but the text
and data spaces are visible to each of the threads. A thread that is the only
member of its group is equivalent to a process.
Version 1.0
EGL version 1.0, approved on July 23, 2003, is the original version of EGL. EGL
was loosely based on GLX 1.3, generalized to be implementable on many differ-
ent operating systems and window systems and simplified to reflect the needs of
embedded devices running OpenGL ES .
A.1 Acknowledgements
EGL 1.0 is the result of the contributions of many people, representing a cross
section of the desktop, hand-held, and embedded computer industry. Following
is a partial list of contributors, including the company that they represented at the
time of their contribution:
Aaftab Munshi, ATI
Andy Methley, Panasonic
Carl Korobkin, 3d4W
Chris Hall, Seaweed Systems
Claude Knaus, Silicon Graphics
David Blythe, 3d4W
Ed Plowman, ARM
Graham Connor, Imagination Technologies
Harri Holopainen, Hybrid Graphics
Jacob Strom, Ericsson
Jani Vaarala, Nokia
Jon Leech, Silicon Graphics
Justin Couch, Yumetech
Kari Pulli, Nokia
Lane Roberts, Symbian
35
36 APPENDIX A. VERSION 1.0
Mark Callow, HI
Mark Tarlton, Motorola
Mike Olivarez, Motorola
Neil Trevett, 3Dlabs
Phil Huxley, Tao Group
Tom Olson, Texas Instruments
Ville Miettinen, Hybrid Graphics
37
38 INDEX
GL EXTENSIONS, 29
GL TEXTURE 2D, 6
glBindTexture, 6
glFinish, 6, 26