\

Hands-On Graphics Without X11

166 points - 01/17/2025

Source
  • arghwhat

    01/17/2025

    These interfaces can be cute to play with, but there's a reason that fbdev is deprecated on Linux - it's not a good interface outside toy examples. wscons may be more powerful, but I don't think it can be used to fully enable modern accelerated display devices, although do correct me if I'm wrong.

    Despite some confusion in terminology, modern interfaces also operate on frame buffers, but with an API for switching them out atomically. Likewise, your display server (at least modern ones) just take your client window as a completed frame buffer, and mainly serve to let multiple applications all show their frame buffers without having to worry about what other applications are doing. Frame buffers all the way down, just with support for DMA, atomicity, fancy formats and color spaces, etc.

    You can use the appropriate modern APIs to make a single, exclusive graphical application with all the benefits of modern display hardware easily enough. That is, after all, what your display server is. You just don't gain much - just a little bit of saved sideband IPC.

    X11 makes it seem like a display server is a complicated thing that has to support drawing and what not, but with alternatives like Wayland, a full screen client buffer is handed off zero-copy from the client application tot he hardware without being looked at.

      • jmmv

        01/17/2025

        > wscons may be more powerful, but I don't think it can be used to fully enable modern accelerated display devices, although do correct me if I'm wrong.

        As I mentioned in the text, I think that's the difference between WSDISPLAYIO_MODE_MAPPED and WSDISPLAYIO_MODE_DUMBFB. The former allows access to the hardware registers whereas the latter does not. Obviously, if you choose to use the former, then you are tied to a specific graphics driver. (But I'm not sure of this.)

        And yes, agree, what I described is not great for performant results, but there is a lot you gain from the simplicity of this approach if all you want is toy around. I feel we lost a lot of this simplicity over the years, but it's "still there" if you don't care about optimal performance.

          • taeric

            01/17/2025

            Completely agreed on the feeling that we lost a lot by moving away from some of the simpler interface options. Particularly for introductory and play purposes. Specifically, even.

            • arghwhat

              01/17/2025

              > I feel we lost a lot of this simplicity over the years, but it's "still there" if you don't care about optimal performance.

              You lost some simplicity in going "straight to the metal", but at the same time it never really went straight to the metal because things have not actually worked that way for ages, nor do anyone really want to deal with exclusive access.

              On the other hand, you can make a window with a shm buffer on your display server, giving you the same drawing simplicity of the old interfaces but without having to deal with fbdev, evdev, exclusive access, etc. - with that in mind, I do not think anything educational was lost.

              No harm in playing around though.

              • mrlonglong

                01/19/2025

                I really miss the ability to scrollback on a simple console in Linux. Using NetBSD was just like going back to the days when Linux last had that.

            • panic

              01/18/2025

              BTW if you want to learn how to put stuff on the screen without any display server on modern Linux, the kmscube example project is a great starting point: https://gitlab.freedesktop.org/mesa/kmscube

          • pjmlp

            01/17/2025

            On a parallel note, this brought memories of SVGALib.

            https://en.m.wikipedia.org/wiki/SVGALib

              • 01/18/2025

                • lizknope

                  01/18/2025

                  I remember running "sdoom" instead of "xdoom" on Linux. It did seem faster on sdoom using SVGAlib.

                  • keyle

                    01/18/2025

                    Never heard of it before, interesting!

                      • pjmlp

                        01/18/2025

                        Yeah, it was a long time ago that it mattered, grey dog over here.

                • seba_dos1

                  01/18/2025

                  > Same font, same colors, same… everything? Other than for the actual text they display, they look identical, don’t they?

                  Funny to see that written under two screenshots with clearly different fonts, and even different colors (though not so clearly; but still different enough to make me check).

                    • jmmv

                      01/18/2025

                      It’s the same font data but not the same rendering code. The spacing between the characters is probably different.

                        • seba_dos1

                          01/18/2025

                          It's not. Just look at it please! Glyphs are completely different. One font is serif, one is sans-serif. It's the most obvious when you look at p, y, r, a, s...

                            • jmmv

                              01/18/2025

                              Hah, I was convinced I picked the same font file from NetBSD... and didn't really notice the difference on the small screen I'm running this on!

                  • zfg

                    01/18/2025

                    Avalonia (https://avaloniaui.net/) supports the Direct Rendering Manager on Linux for graphics without X11 or Wayland:

                    https://avaloniaui.net/blog/unleashing-net-on-embedded-linux

                    https://docs.avaloniaui.net/docs/guides/platforms/rpi/runnin...

                    • segasaturn

                      01/17/2025

                      I remember Links, the text-based browser that runs in your terminal, had a framebuffer mode that you could use to get rudimentary graphical web browsing on a system with no X11 installed.

                        • prmoustache

                          01/17/2025

                          I think netsurf can still be compiled for fb.

                          • baq

                            01/18/2025

                            May I introduce you to https://www.brow.sh/

                            • LtWorf

                              01/17/2025

                              Yeah, also mpv has a framebuffer driver. AFAIK Qt has one as well, so any Qt program could run without X/wayland.

                        • makz

                          01/18/2025

                          Awesome! I was thinking about playing with this on some BSD like two months ago.

                          • int_19h

                            01/19/2025

                            Once upon a time there was a tiny library called TinyPTC that let you write code like this:

                               if (!ptc_open("test",WIDTH,HEIGHT)) return 1;
                               while (1)
                               {
                                   for (index=0; index<SIZE; index++)
                                   {
                                       noise = seed;
                                       noise >>= 3;
                                       noise ^= seed;
                                       carry = noise & 1;
                                       noise >>= 1;
                                       seed >>= 1;
                                       seed |= (carry << 30);
                                       noise &= 0xFF;
                                       pixel[index] = (noise<<16) | (noise<<8) | noise;
                                   }
                                   ptc_update(pixel);
                               }
                            
                            I wish we had something equally simple these days.

                            • ykonstant

                              01/17/2025

                              Very nice, I am very interested in raw framebuffer graphics and applications.

                                • mysterydip

                                  01/17/2025

                                  Check this out: https://github.com/vvaltchev/tfblib

                                  It worked well for a hobby project. I had issues on certain specific displays I think due to the color depth requirement.

                              • synergy20

                                01/18/2025

                                i think that's what sdl provides? except sdl can do more

                                  • incanus77

                                    01/18/2025

                                    No, SDL provides a window/context in the existing windowing layer.

                                      • jpc0

                                        01/18/2025

                                        SDL does not need a windowing layer... There might be better docs somewhere but this should act as enough proof for you without linking directly to the source code.

                                        https://wiki.libsdl.org/SDL2/SDL_HINT_KMSDRM_REQUIRE_DRM_MAS...

                                          • incanus77

                                            01/19/2025

                                            Thank you, I stand corrected! I had used it in the windowing sense and didn’t recall the other option!

                                        • bregma

                                          01/18/2025

                                          SDL can provide a context in the native windowing system, if you ask it to. Or not. You have to ask for it though, it's not the default.

                                          • synergy20

                                            01/18/2025

                                            I think sdl works directly with fb when using fb as a backend,no windows system is needed

                                    • 01/18/2025

                                      • unit149

                                        01/18/2025

                                        [dead]