GLX offscreen rendering in headless system

621 views Asked by At

I am try to render GLX appliations in a Linux headless system(such as Linux server version), with no display and no desktop.

However, when I run a GLX sample, I got the following errors:

  1. XOpenDisplay failed: Can not open display. Maybe no DISPLAY environment variable impacts.
  2. DefaultScreen and RootWindow failed: May be no screen and no desktop in here.

I have tried some methods:

  • GLX pbuffer: it fails because can not execute above xlib apis successfully. It seems that these xlib apis depends on screen and desktop.
  • EGL pbuffer: It works. But converting GLX to EGL is difficult, including that not only apis, but also some GLX parameters.

So, is there another method can offscreen rendering GLX applications in headless system?

Thanks.

1

There are 1 answers

0
Velkan On

There is XVFB - headless X (https://en.wikipedia.org/wiki/Xvfb).

Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol.

Most Linux distribution should have it in the package repositories.

After installation it's basically this to run an application:

xvfb-run my-application

It launches an off-screen X just for the application.

That will give only software graphics though (execute xvfb-run glxinfo to see what's used).

To redirect GL calls to the real 3D X there is VitrualGL (https://www.virtualgl.org/).

This will run off-screen and hardware-accelerated:

xvfb-run vglrun my-application

There are some discussions about the capabilities of these tools: https://unix.stackexchange.com/questions/137567/glx-extension-not-working-properly-with-xvfb