3

I want to create an opengl context but that context must be created without a monitor attach to the system. The reason I want this is because this program should ran in a linux ubuntu server. Inside a docker image to be specific. I'm using many opengl libraries including modern opengl(GLSL), GLFW, glad and glm. I've found this question but I'm not sure whether or not one of the methods will work and it might be a bit outdated. I've also seen someone using something like this on an obsolete site but I'm not sure how to implement it:

glXMakeContextCurrent(display,None,None,context);

I think it still needs a window as display, if not what is the type of display and context variable and where can i download glX?

Edit: I'm only using GLFW for window/context creation on my local machine so I can exclude it.

Turgut
  • 711
  • 3
  • 25
  • 1
    I'm somewhat sure you can emulate presence of a display via some Linux commands – Alexey S. Larionov Aug 11 '22 at 10:09
  • @AlexeyLarionov How can I emulate one? Can you put me on the right track please? – Turgut Aug 11 '22 at 10:15
  • @AlexeyLarionov I've tried running `apt-get install xserver-xorg-video-dummy` but its stuck at "Choose a country for keyboard layout" question, I answer it but when I press enter nothing happens. What should i do? – Turgut Aug 11 '22 at 10:34
  • 1
    I've never used it myself, but there is [xvfb](https://en.wikipedia.org/wiki/Xvfb#:~:text=Xvfb%20or%20X%20virtual%20framebuffer,without%20showing%20any%20screen%20output.). Should be possible to install with `sudo apt-get install xvfb` and use for your application executable via `xvfb-run -a "your command"` – Alexey S. Larionov Aug 11 '22 at 10:36
  • That worked! Can you post it as an answer so i can accept is pelase? – Turgut Aug 11 '22 at 11:39
  • 2
    You could also look at EGL, which is designed for this purpose and for this reason, and will probably replace GLX in the future (e.g. Wayland uses EGL) – user253751 Aug 11 '22 at 22:42

1 Answers1

2

You can use an X Virtual Framebuffer that allows to emulate presence of a physical display in Linux.

It can be installed via

apt-get install xvfb

And used as

xvfb-run -a "your command"
Alexey S. Larionov
  • 6,555
  • 1
  • 18
  • 37