C/C++ Draw graphics on display without Xorg




Reaction score: 163
Messages: 1,150

Thank you Aragats!
Is /usr/include/sys/fbio.h in FreeBSD the unique possibility? (like does the layer vgl or without vgl,
directly using signal, consio, ioctl, fbio.


Son of Beastie

Reaction score: 2,517
Messages: 3,377

If the goal is education and maths, I suggest the following. Start by getting a good computer graphics textbook; the kind of thing that undergraduate CS majors would read. I don't own one (not a UI person), but a friend used to have a good one in the 1980s.

Then find some programming system that allows you to directly draw points, lines, rectangles, and circles. My first approach would actually be to either do this in postscript (which also teaches a highly useful programming language and programming style, namely postscript and stack-based programming), or in HTML5 with Javascript. In HTML5, just create a canvas and a graphics context, and then use functions such as context.putImageData to put graphics elements into the canvas. That will be much easier to start with, and will teach you how to get graphics built.

If you really insist on using the hardware frame buffer, then the techniques that aragats suggested sound reasonable. Another approach I would suggest: Find some framework (like Kivy or Qt5) which is capable of using the frame buffer under FreeBSD, and read the source code so as to see how they do it. That will give you a starting point for the techniques experienced programmers use; then combine it with reading documentation for the API they use, and combining it with a good textbook.



Reaction score: 163
Messages: 1,150

wolfram mathematica is widely used today.

Framebuffer is still available.

An user interface can be of course programmed in Java, Qt, GTK,..., to be used with a mouse / pointer.
A graphical user interface and the computer mouse have become most often used with a personal computer.
It is however important to keep things like it should, not to use QT for framebuffer, if it is not necessary.

There is a quote attributed to Einstein that may have arisen as a paraphrase of the above quote, commonly given as “Everything should be made as simple as possible, but no simpler,” "Everything should be made as simple as possible, but not simpler", or “Make things as simple as possible, but not simpler.”

fb looks stable. It looks sufficiently available for next coming years.
It runs without need of Xorg installation or additional graphical env, like coming wayland (or other).
Framebuffer does not need numerous layers of layers of libraries.
It does not depends on drivers for GL.
It does not require or need regular code updates/maintainance.
It has a clean usage of the memory and resource, and it allows to protect our environment.
It allows to do not use Wayland, SDL, QT, GTK,...

For some specific areas of applications, a low specs-computer like a PI for educative purpose can display highly complex 2D plots/outputs of simulations. For simple graphical applications and specific requirements, it can be a convenient, versatile option, due to previously mentioned advantages.
Furthermore, it is cheap, compilable, and widely available.

But, in term of longevity, much better is Microsoft MSDOS or FreeDOS. But it needs the environment to run it. MSDOS would be more reliable, because it runs on any kind of platforms and it will be stable over years.

Last but not least, low-power consumption devices and Energy Efficient Computing are important for education, for students, ... academic. The earlier getting used to it, the better. It protects our planet.



Reaction score: 163
Messages: 1,150

this was easier.

  • with sysutils/jfbterm you can get not limited to 256 chars unicode support
  • www/w3m allows you to browse www sites with images on jfbterm
  • using libSDL + libvgl you can play some videos or graphical games

today it is possible still to use the fbio.h by passing information using framebuffer.

In the past, there was vgl, but it used <sys/io.h> which is no longer there.
hence vgl is outdated. https://github.com/openglredbook/examples/blob/master/include/vgl.h

In the past, w3m could use /dev/fb0
ls -ltra /dev/fb0
crw------- 1 root wheel 0x2f Apr 14 17:00 /dev/fb0

The position of 0x3c4 was being used.

it was actually possible to write on framebuffer of BSD.

It might be however still possible.

Ideally would be to watch a movie using framebuffer and mplayer -vo fbdev ...
chmod 777 /dev/fb0 is your unsecured friend.

Today this code can be adapted to run on > 11.x
but it needs libkvm from freebsd master.


New Member

Messages: 5

OP, what is the application? Is this charting for HFT for example?
Why did you choose FreeBSD? for it's network superiority?

I am curious as I am looking to draw HFT charts to kernel framebuffer and need the lowest layer access for simple X/Y charts.

Thank you kindly.



Reaction score: 595
Messages: 1,349

With clean install (kernel.txz and base.txz) without installation of Xorg, which opportunities might be being given to draw graphics [...] on the display?
if you use the newcons ("vt") you don't need any extra software to draw graphics.
Just paint on the screen using the mouse:

Explanation from a 2016 PR (see there if you want more details)
If one plays with all three mouse buttons, it is quite easy to use vt as a painting program.
Sorry if that answer is not what you expected ;)


New Member

Messages: 16

SVGAlib is definitely not dead and it is still the easiest and best way to deal with graphics using pure text console. I maintain the current version[1] which builds on modern Linux (don't know about FreeBSD as I last used it many years ago).

[1] https://github.com/akosela/svgalib