1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
<refentry xmlns="http://docbook.org/ns/docbook" version="5.0" xml:base="" xml:id="eglIntro">
<info>
<copyright>
<year>2003-2018</year>
<holder>The Khronos Group Inc.</holder>
</copyright>
</info>
<refmeta>
<refentrytitle>eglIntro</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refname>eglIntro</refname>
<refpurpose>
introduction to managing client API rendering through the
<acronym>EGL</acronym> API.
</refpurpose>
</refnamediv>
<refsect1 xml:id="overview"><title>Overview</title>
<para>
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.
</para>
<para>
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
<citerefentry><refentrytitle>eglGetPlatformDisplay</refentrytitle></citerefentry>
or
<citerefentry><refentrytitle>eglGetDisplay</refentrytitle></citerefentry>.
To initialize and
query what EGL version is supported on the display
connection, call
<citerefentry><refentrytitle>eglInitialize</refentrytitle></citerefentry>.
</para>
<para>
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
<citerefentry><refentrytitle>eglQueryString</refentrytitle></citerefentry>.
</para>
<para>
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.
</para>
<para>
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.
</para>
<para>
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.
</para>
<para>
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
requires.
<citerefentry><refentrytitle>eglChooseConfig</refentrytitle></citerefentry>
returns an <type>EGLConfig</type> matching the required
attributes, if any. A complete list of EGL frame buffer
configurations can be obtained by calling
<citerefentry><refentrytitle>eglGetConfigs</refentrytitle></citerefentry>.
Attributes of a particular EGL frame buffer configuration
can be queried by calling
<citerefentry><refentrytitle>eglGetConfigAttrib</refentrytitle></citerefentry>.
</para>
<para>
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
<citerefentry><refentrytitle>eglGetConfigAttrib</refentrytitle></citerefentry>.
For pixel buffers, no underlying native resource is
required.
</para>
<para>
To create an EGL window surface from a native window, call
<citerefentry><refentrytitle>eglCreateWindowSurface</refentrytitle></citerefentry>.
To create an EGL pixmap surface from a native pixmap, call
<citerefentry><refentrytitle>eglCreatePixmapSurface</refentrytitle></citerefentry>.
To create a pixel buffer (pbuffer) surface (which has no
associated native buffer), call
<citerefentry><refentrytitle>eglCreatePbufferSurface</refentrytitle></citerefentry>
To create a pixel buffer (pbuffer) surface whose color
buffer is provided by an OpenVG <type>VGImage</type>, call
<citerefentry><refentrytitle>eglCreatePbufferFromClientBuffer</refentrytitle></citerefentry>.
Use
<citerefentry><refentrytitle>eglDestroySurface</refentrytitle></citerefentry>
to release previously allocated resources.
</para>
<para>
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
<citerefentry><refentrytitle>eglCreateContext</refentrytitle></citerefentry>.
The type of client API context created (OpenGL ES, OpenVG,
etc.) can be changed by first calling
<citerefentry><refentrytitle>eglBindAPI</refentrytitle></citerefentry>.
</para>
<para>
An EGL rendering context may be bound to one or two EGL
surfaces by calling
<citerefentry><refentrytitle>eglMakeCurrent</refentrytitle></citerefentry>.
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
<citerefentry><refentrytitle>eglMakeCurrent</refentrytitle></citerefentry>
is called with different arguments.
</para>
<para>
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
<citerefentry><refentrytitle>eglWaitClient</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglWaitNative</refentrytitle></citerefentry>,
and possibly by calling other platform APIs.
</para>
</refsect1>
<refsect1 xml:id="examples"><title>Examples</title>
<para>
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.
</para>
<programlisting>
#include <stdlib.h>
#include <unistd.h>
#include <EGL/egl.h>
#include <GLES/gl.h>
typedef ... NativeWindowType;
extern NativeWindowType createNativeWindow(void);
static EGLint const attribute_list[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_NONE
};
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, &config, 1, &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);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
eglSwapBuffers(display, surface);
sleep(10);
return EXIT_SUCCESS;
}
</programlisting>
</refsect1>
<refsect1 xml:id="notes"><title>Notes</title>
<para>
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.
</para>
</refsect1>
<refsect1 xml:id="usingeglextensions"><title>Using EGL Extensions</title>
<para>
All supported EGL extensions will have a corresponding definition in
<filename>egl.h</filename> and a token in the extension strings returned
by
<citerefentry><refentrytitle>eglQueryString</refentrytitle></citerefentry>.
</para>
</refsect1>
<refsect1 xml:id="futureeglversions"><title>Future EGL Versions</title>
<para>
<citerefentry><refentrytitle>eglInitialize</refentrytitle></citerefentry>
and
<citerefentry><refentrytitle>eglQueryString</refentrytitle></citerefentry>
can be used to determine at run-time what version of EGL is available.
To check the EGL version at compile-time, test whether
<constant>EGL_VERSION_<replaceable>x</replaceable>_<replaceable>y</replaceable></constant>
is defined, where <replaceable>x</replaceable> and
<replaceable>y</replaceable> are the major and minor version
numbers.
</para>
</refsect1>
<refsect1 xml:id="files"><title>Files</title>
<variablelist>
<varlistentry>
<term><filename>GLES/egl.h</filename></term>
<listitem><para>
EGL header file
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 xml:id="seealso"><title>See Also</title>
<para>
<!--
<citerefentry><refentrytitle>glIntro</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glFinish</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glFlush</refentrytitle></citerefentry>,
-->
<citerefentry><refentrytitle>eglBindAPI</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglChooseConfig</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglCreateContext</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglCreatePbufferFromClientBuffer</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglCreatePbufferSurface</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglCreatePixmapSurface</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglCreateWindowSurface</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglDestroyContext</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglDestroySurface</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglGetConfigs</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglGetDisplay</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglGetPlatformDisplay</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglInitialize</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglMakeCurrent</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglQueryString</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglSwapBuffers</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglTerminate</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglWaitGL</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>eglWaitNative</refentrytitle></citerefentry>
</para>
</refsect1>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="copyright.xml"/>
</refentry>
|