I'm teaching my son programming "the right/hard way", so we're starting with C, like real men :)
Printing text to the console is fun, but I still remember the exhilaration of switching my old i386 to the 320x200x256 mode and drawing a few colored rectangles... back in the day it was as easy as invoking int 10h
and then you just write bytes to [A000:0000]
to draw pixels on the screen.
With modern Linux, however, such low-level access to the hardware seems to be more complicated (for obvious reasons). I've briefly looked at mmap
-ing /dev/fd0
as described here - turns out there's no /dev/fb0
device on my Ubuntu 13.04. I also looked at using svgalib
- however, their example code displays nothing on my monitor.
So the question is: are there easy ways to obtain direct access to video memory in modern Linux which do not require much system configuration and boilerplate code? It does not have to be a fullscreen access - opening an X window and drawing pixels there would be fine too, as long as it's done via writing data directly to memory.
Instead of accessing the screen memory directly (which is fraught with more pitfalls than one can believe), you should consider using Simple DirectMedia Layer for your graphics (and much more!) and letting the OS handle drawing it to the screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With