Linux Graphics Programming

There was a time when embedded system developers didn’t need to worry about graphics. When you have a PIC processor and two-line LCD, there isn’t much to learn. But if you are deploying Linux-based systems today, graphics are a real possibility. There are many options for doing Linux graphics including Wayland, X11, and frame buffers. Confused? This tutorial can help. The sections on Wayland and Mir are under construction, but that’s probably not what you are going to be using on a typical hacker project for the foreseeable future, anyway.

Of course, even inside those broad categories, you have multiple choices. If you are doing X11, for example, you can go low-level or pick any of a number of high-level libraries.

The tutorial assumes you understand C and basic Linux programming. It has two sections, really. One on how to plot points on the screen and another that covers basic graphics algorithms for drawing things like circles. We’d be interested in some benchmarks about the relative performance between the different raw drawing methods.

If you have a graphics-intensive application, the Raspberry PI 3 isn’t too bad. However, you can get dedicated hardware that will do better. You can even roll your own if you are so inclined.

24 thoughts on “Linux Graphics Programming

    1. I started out with curses in a project (github.com/girst/minesviiper), only to then re-implement it with the few escape sequences I actually needed. ui-performance improved drastically. Curses is a nice prototyping tool, but unless you need all of its advanced features, you might be better off just doing it “by hand”. not too hard.

  1. The first example compiles and caused a seg fault when I ran it. Then I suspected that the fd0 device might need root permission so I ran it with sudo and now it turns my screen purple. It is not as the author wrote a fleeting effect so it is easy to note that the program worked.

    The primitive shape code requires a function called draw() which is not defined anywhere.

  2. I would like to know apart from dumping to the /dev/fb0 which I got confused on /sys/class/graphics/fb0 vs fbcon… Which is the entire screen. It shows on the terminal console but not the screen.

    Anyone help, graphical programming in Ubuntu fedora Linux at port layer or PCI card to CPU processing methods. FB graphic layer is direct to physical screen and to the daemon layer.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.