Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

For educational purposes, I'd like to write an application on a Linux environment that can process keyboard events and draw graphics without huge dependencies like X or SDL. I presume that this must be possible, because X and SDL are just programs themselves, so they must rely on other methods inherent to the environment. Is this understanding correct?

If so, where might I learn to write such a program? My limited experience tells me that it would involve making calls to the kernel, and/or writing to special files; however, I haven't been able to find any tutorials on the matter (I am not even sure what to Google).

Also, in case it is relevant, I am running Debian Squeeze on Virtualbox. I have used a netinst cd without networking, so there isn't much installed on it currently. I will install gcc, but I am hoping I can get by with nothing more.

share|improve this question
I don't know if this is what your looking for but it gives color. ncurses –  Joe Mar 28 '12 at 6:41
You may want to take a look to the Linux Framebuffer. –  mouviciel Mar 28 '12 at 7:22
In addition to X and fbdev, there's also SVGALib, which hasn't been updated since 2001. –  user16764 Jun 21 '12 at 16:59
If you really want to do bare-metal programming (e.g. calling an interrupt to set the video mode), may I suggest DOS? –  user16764 Jun 21 '12 at 17:23
This looks helpful: tldp.org/HOWTO/Framebuffer-HOWTO –  Chinasaur Sep 10 '12 at 18:44

2 Answers 2

up vote 8 down vote accepted

X is practically the most low-level graphics API a Linux application will likely use on a modern Linux Desktop. Most applications won't even bother going that deep and will instead use a GUI toolkit implementation like GTK or Qt.

Below that there's only the hardware drivers and probably some X-internal APIs for the drivers. But those are not meant or designed to be used by normal userspace applications.

You could use the kernel framebuffer device (fbdev), but I don't know how well that supports modern graphics API.

share|improve this answer
X is able to use the framebuffer. GTK and Qt, while usually targeting X, are also able to target the framebuffer. –  AProgrammer Mar 28 '12 at 6:55
@AProgrammer: that's true, but it doesn't really change my answer. Most GTK/Qt applications run on X as at the underlying framework (at least for now) and almost no applications use the raw X API directly. –  Joachim Sauer Mar 28 '12 at 6:57
The framebuffer should, at the very least, support running the graphics card in the standard VESA modes. It might not be perfect (the number of different resolutions is limited, for example, and I don't think any widescreen modes are supported), but it will give you graphics on a Linux system with a minimum number of dependencies. –  Michael Kjörling Mar 28 '12 at 9:55

If you want to get input events without using X then you will have to read them out of device nodes. Linux has a generic input subsystem called evdev that most drivers take advantage of. So to read input events, you can read from any of the device nodes in /dev/input.

An easy trick to find the mouse device node is to run "cat" on the device nodes one at a time, moving the mouse during each "cat". If you see data coming out to the screen then that is your mouse device node. The relevant header file is linux/input.h. For an example of how to use it, look at the source for xevdev driver.

For low level graphics manipulation, if you are really feeling ambitious, you can generally memory map the framebuffer and do your own bit blts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.