OpenGL Overview

How LVGL's OpenGL support fits together on Linux: which display drivers create a context, which draw units render on the GPU, and how the two combine.

Edit on GitHub

Overview

OpenGL is a cross-platform, hardware-accelerated graphics API, and OpenGL ES is the subset designed for embedded and mobile hardware. LVGL uses it on Linux for three reasons: to offload rendering to the GPU, to embed LVGL content inside existing OpenGL applications, and to render 3D content.

LVGL's OpenGL support comes in two halves, and you generally need one of each:

  • Display drivers create and own the OpenGL context, and put the finished frame on screen.
  • Draw units do the actual rendering with OpenGL instead of the CPU.

Enabling a driver with an OpenGL backend but no GPU draw unit is valid and sometimes what you want, LVGL can then render using software and use OpenGL to present the result to the display.

Drivers That Create a Context

These drivers create and manage an OpenGL context for you:

DriverHow to get the OpenGL path
DRMLV_LINUX_DRM_BACKEND_EGL
WaylandLV_WAYLAND_USE_EGL
SDLLV_SDL_BACKEND_EGL
GLFWAlways

Every one of them except GLFW uses EGL underneath.

GLFW and EGL are mutually exclusive

LV_USE_GLFW cannot be combined with LV_USE_EGL

The OpenGL Driver can be used to embed LVGL in an application that already owns the context.

Draw Units

Draw unitNotes
NanoVGRecommended. Rasterizes on the GPU, best performance and widest feature coverage
OpenGL ESCaches software-rendered areas as GPU textures. Slower, fewer features.

3D and glTF

The glTF module loads and renders 3D models per the glTF 2.0 specification, with PBR materials, animations and camera control. It needs OpenGL ES 2.0 with some extra extensions.

3D support comes from the GL renderers so a GPU draw unit is required.

For details, see glTF.

See Also

  • NanoVG Draw Unit - the recommended GPU renderer
  • EGL - the layer under most OpenGL paths on Linux
  • DRM - production driver with an EGL backend
  • GLFW - quickest OpenGL setup for development
  • OpenGL Driver - embedding LVGL in an existing context
  • glTF - 3D model rendering

Last updated on

On this page