Bare bone display server in SDL2 or Raylib

Introduction

At my university, during past semester programming class in C, had a painful experience of working with graphics library that was pretty much a simple X11 wrapper. It’s was terrible there was no double buffering implemented, no options to load textures directly into the buffer. And to implement it it would mean to rewrite a huge chunks of this library.

Into the double-buffering hole

But this painfull experience maked me a little bit interested in how Xorg work, and I started to read it’s documentation. That’s was even worse.
Main problems -

  1. Terrible frontend of the website
  2. Terrible navigation
  3. Very few examples
  4. Poorly and not detailed descriptions
  5. Terribly covered usage of the side modules.

The only good Xorg documentation on the Web right now, is Chat-GPT. Perhaphs also Gaybook METAs LlaMa, but I didn’t tested it yet.

And with Wayland, situation isn’t much better… The things which are a little bit better are navigation and website frontend. But still, even for such important thing as double-buffering, you need to google it, to find links on their Dev-forum, where you could find a link to the article which describes how it’s working.

And to make it clear, what I think is a good documentation - Go’s. I hate google a lot, but Go’s documentation is perfect. The worst one? С++ standard documentation - closed sourced(not a big problem, but still :pirate_flag:), just a damn plain PDF, which is besides of all poorly explains things that it must to.

Eeeeeexperimentation

But, we have a 2 well written, low-level GUI libraries, which are multiplatform, supported by the most mainstream languages. And one of them, SDL2 is an industry standard for both low and highlevel apps.
They’re modular, they support Vulkan, they support all kinds of the user inputs and outputs.
And what’s more important, they have a well written documentations.

But, I didn’t found even a proof-of-concepts where someone tried to make a display server with them.
Though they DO support work without Xorg or Wayland, and can directly work with a frame buffer.
But it’s seems that the only one who knows/cares about this functionality are Embeded Systems devs.

Sources:

  1. https://medium.com/@avik.das/writing-gui-applications-on-the-raspberry-pi-without-a-desktop-environment-8f8f840d9867
    1.2 https://avikdas.com/2019/03/04/creating-raspberry-pi-applications-with-raylib-and-ruby-part-2.html
  2. https://www.esp32.com/viewtopic.php?t=16070
  3. https://hackaday.io/project/163464-gaming-on-the-esp32-odroid-go
  4. https://stackoverflow.com/questions/57672568/sdl2-on-raspberry-pi-without-x
  5. https://forum.odroid.com/viewtopic.php?f=95&t=31431
  6. https://itecnote.com/tecnote/c-sdl2-on-raspberry-pi-without-x/
  7. https://wiki.libsdl.org/SDL2/FAQUsingSDL

Why?

    • Decades of legacy code supported by semi-alive DEVs communities, while both SDL2 and Raylib are actively maintained. And SDL2 is widespread and actively used in the industry.
    • Easier to understand, easier to maintain. Though both Wayland and X11 are high-level display servers, their syntax and complexity is higher than in the low-levelish SDL2 and Raylib.
      Once again, even a damn frame-buffer SDL2 and Raylib will handle in most of the cases for you without any additional tinkering. While in both X11 and Wayland it’s a kind of obscure eldritch knowledge that will drive you to instanity.
    • Higher compaitability, SLD2 and Raylib support nigh-everything from the bare bone hardware up to the WASM in Browser. While X11 and Wayland are complex monstrocities which are limited only to the function of a display servers on linux.
    • Less levels of abstarction, less bloat. SDL2 and Raylib are more modular, less complex and display server written in them could have a better integration with desktop, or web-apps which also would use Raylib or SDL2.

How?

IDK, lol.
See you soon, maybe 10 years later, if I will be able manage to have time to handle this as a university-project.
Perhaps I would be remembered by generations as Torvalds. Or cursed like Stroustrup.

I have a dream, to at least run Chrome without X11 or Wayland on Arch Linux, using SDL2 or Raylib. Just a browser covers a needs of the 95% of the users, and if it’s would be able to run Chrome it would be able to do the same with all ZOO of the Electron apps.

Once again about X11

I was higly disappointed when I asked professor at my university, how could I properly use double buffering in X11 and directly load textures? He sayed he don’t know, lol.
So thanks to our AI-brother in Christ, Chat-GPT, I’ve later made some examples of how to do some unobvious stuff with X11, with which google and especially official documentation won’t help much.