Mesa EGL

The current version of EGL in Mesa implements EGL 1.4. More information about EGL can be found at https://www.khronos.org/egl/.

The Mesa’s implementation of EGL uses a driver architecture. The main library (libEGL) is window system neutral. It provides the EGL API entry points and helper functions for use by the drivers. Drivers are dynamically loaded by the main library and most of the EGL API calls are directly dispatched to the drivers.

The driver in use decides the window system to support.

Build EGL

  1. Run configure with the desired client APIs and enable the driver for your hardware. For example

    $ ./configure --enable-gles1 --enable-gles2 \
                  --with-dri-drivers=... \
                  --with-gallium-drivers=...
    

    The main library and OpenGL is enabled by default. The first two options above enables OpenGL ES 1.x and 2.x. The last two options enables the listed classic and Gallium drivers respectively.

  2. Build and install Mesa as usual.

In the given example, it will build and install libEGL, libGL, libGLESv1_CM, libGLESv2, and one or more EGL drivers.

Configure Options

There are several options that control the build of EGL at configuration time

--enable-egl
By default, EGL is enabled. When disabled, the main library and the drivers will not be built.
--with-egl-driver-dir
The directory EGL drivers should be installed to. If not specified, EGL drivers will be installed to ${libdir}/egl.
--with-platforms

List the platforms (window systems) to support. Its argument is a comma separated string such as --with-platforms=x11,drm. It decides the platforms a driver may support. The first listed platform is also used by the main library to decide the native platform.

The available platforms are x11, drm, wayland, surfaceless, android, and haiku. The android platform can either be built as a system component, part of AOSP, using Android.mk files, or cross-compiled using appropriate configure options. The haiku platform can only be built with SCons. Unless for special needs, the build system should select the right platforms automatically.

--enable-gles1
--enable-gles2
These options enable OpenGL ES support in OpenGL. The result is one big internal library that supports multiple APIs.
--enable-shared-glapi
By default, libGL has its own copy of libglapi. This options makes libGL use the shared libglapi. This is required if applications mix OpenGL and OpenGL ES.

Use EGL

Demos

There are demos for the client APIs supported by EGL. They can be found in mesa/demos repository.

Environment Variables

There are several environment variables that control the behavior of EGL at runtime

EGL_PLATFORM

This variable specifies the native platform. The valid values are the same as those for --with-platforms. When the variable is not set, the main library uses the first platform listed in --with-platforms as the native platform.

Extensions like EGL_MESA_drm_display define new functions to create displays for non-native platforms. These extensions are usually used by applications that support non-native platforms. Setting this variable is probably required only for some of the demos found in mesa/demo repository.

EGL_LOG_LEVEL
This changes the log level of the main library and the drivers. The valid values are: debug, info, warning, and fatal.

EGL Drivers

egl_dri2

This driver supports both x11 and drm platforms. It functions as a DRI driver loader. For x11 support, it talks to the X server directly using (XCB-)DRI2 protocol.

This driver can share DRI drivers with libGL.