Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Run SFML without a window for linux with no X11 installed  (Read 1640 times)

0 Members and 1 Guest are viewing this topic.

Khatharr

  • Newbie
  • *
  • Posts: 11
    • View Profile
Run SFML without a window for linux with no X11 installed
« on: March 06, 2023, 01:55:41 am »
Hello. I've used SFML in Windows to create a utility that will generate a png representation of some text data. The program does not create a window, since it's just rendering to an sf::RenderTexture and then getting the texture out of that and saving it to a file. I'm intending to use this on a Raspberry Pi 4 that's running OSMC (2022.03-1) in order to generate a background image for my media center.

I was able to install SFML and compile the program, but when I try to run the program I get the output:
Quote
Failed to open X11 display; make sure the DISPLAY environment variable is set correctly

X is not installed on this device, since the OS generates its own GUI. I'm wondering if there's something I can do to bypass the requirement for it, since SFML is not being required to draw to the screen. I'm fine with downloading the SFML source and making changes, but I'm not familiar enough with the situation to know where to start looking.

Any advice would be greatly appreciated.   :D
« Last Edit: March 06, 2023, 02:08:43 am by Khatharr »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Run SFML without a window for linux with no X11 installed
« Reply #1 on: March 06, 2023, 10:51:53 am »
That's one of the main reason we had help from some community members to add support for DRM/KVM for SFML 2.6

Build SFML with the SFML_USE_DRM flag set in CMake.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Khatharr

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Run SFML without a window for linux with no X11 installed
« Reply #2 on: March 06, 2023, 12:17:11 pm »
Oh, cool.

Thank you!  ;D

Khatharr

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Run SFML without a window for linux with no X11 installed
« Reply #3 on: March 07, 2023, 12:29:41 am »
So I grabbed the SFML 2.6.x source from GitHub, and I installed as follows:
Quote
mkdir build
cd build
cmake .. -DSFML_USE_DRM=TRUE
make -j4
sudo make install
sudo ldconfig

and then I was able to build my project with:
Quote
g++ main.cpp -lsfml-system -lsfml-graphics -o imgGen.exe

but when I run the exe I get:
Quote
No drm device found!
Could not open drm device
Error initializing DRM
Segmentation fault

I'm not familiar with DRM. Do I need to install/include some driver libraries for it or something?

--

Reading a little more about it, it seems that it has something to do with "/dev/dri/card*". I have card0 and card1 in there.
« Last Edit: March 07, 2023, 04:10:51 am by Khatharr »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Run SFML without a window for linux with no X11 installed
« Reply #4 on: March 07, 2023, 08:53:47 am »
I'm not really familiar with it either, but you'll need some DRM driver.
Hope a web search will reveal some more information.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Khatharr

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Run SFML without a window for linux with no X11 installed
« Reply #5 on: March 07, 2023, 09:05:39 am »
I'll try asking the OSMC people about it and also hunt around google a bit more. If I figure it out I'll post the solution here.

Thank you for helping me get this far!

Khatharr

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Run SFML without a window for linux with no X11 installed
« Reply #6 on: May 21, 2023, 11:51:57 pm »
After a lot of running around I haven't gotten very far.

While snooping around I did notice https://github.com/SFML/SFML/pull/2442 which added Mesa support in order to allow software rendering in the CI. Is it possible to compile SFML to use Mesa and LLVMpipe in order to sidestep the driver issue? The performance hit would be irrelevant in my use case, since I'm only drawing one frame.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Run SFML without a window for linux with no X11 installed
« Reply #7 on: May 22, 2023, 07:43:36 am »
If that's easier to setup than DRM, then sure! Keep in mind that, this is only available on the master branch, which is targeting WIP SFML 3 with a few breaking changes.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything