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:
XOpenDisplayfailed: Can not open display. Maybe no DISPLAY environment variable impacts.DefaultScreenandRootWindowfailed: 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.
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:
It launches an off-screen X just for the application.
That will give only software graphics though (execute
xvfb-run glxinfoto 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:
There are some discussions about the capabilities of these tools: https://unix.stackexchange.com/questions/137567/glx-extension-not-working-properly-with-xvfb