Develop OpenGL Apps In A Docker Container Without GPU
Introduction
When developing graphics applications such as OpenGL or Vulkan apps, we typically using hardware acceleration need a graphics card (Graphics Processing Unit, aka. GPU) to render graphics for better performance and visual quality.
However, in some cases, we may not have access to a GPU, such as headless cloud server or in a CI/CD environment.
In this blog post, I will show you how to develop OpenGL applications inside a Linux server environment which is running in a GPU-less Docker container (in my case, a MacBook Pro with Apple Silicon M3).
Github repo yrom/docker-egl-opengl
Overview
On a headless Linux server without a GPU, we can use the software implementation of OpenGL provided by Mesa.
About Mesa
Mesa is an open-source implementation of OpenGL that provides software rasterizers inside its Gallium driver, such as softpipe and LLVMpipe, for CPU-based rendering.
The Gallium LLVMpipe driver uses LLVM to do runtime code generation with LLVM IR, is multithreaded and offers better performance than softpipe.
Read more about Mesa's llvmpipe.
On Linux, EGL is commonly used as the integration layer between OpenGL and the native windowing system, such as X window system and Wayland.
EGL also supports off-screen rendering by creating an headless surface called Pbuffer (pixel buffer), which enables rendering without any real display or window.
RTT (Render To Texture) with EGL + OpenGL
Image made by author