Low-level (Linux framebuffer) graphics programming tutorial


62 posts   Page 3 of 3   1, 2, 3
by -rst- » Thu Dec 03, 2015 3:09 pm
Now that I 'was woken up' ;) a new post (quick & short for now) about palette animation (color cycling).
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by -rst- » Wed Feb 10, 2016 2:38 pm
Forgot to mention here: a new post two weeks ago around image color format conversion (based on discussion here https://www.raspberrypi.org/forums/view ... 10#p892207 )

http://raspberrycompote.blogspot.ie/201 ... ry-pi.html

And another quick piece on palette animation / color cycling - slightly more interesting and inspiring demo hopefully :)

http://raspberrycompote.blogspot.com/20 ... -more.html
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by -rst- » Thu Feb 11, 2016 12:07 pm
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by -rst- » Wed Feb 24, 2016 4:56 pm
Simple example on reading in an image file and displaying the image http://raspberrycompote.blogspot.ie/201 ... re_24.html
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by itsagoodquestion » Sat Mar 05, 2016 11:27 pm
Wow... this is a lot of fun, it's really similar to GDI in Windows! I would really, really like to get this working on my raspberry pi v2 b+, but whenever I run this code - http://raspberrycompote.blogspot.com.ar ... -part.html - the entire screen goes black. I have my Pi hooked up to a small TV over HDMI. Can you tell me how to fix this please? Thanks!
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm
by -rst- » Mon Mar 07, 2016 9:40 am
Hmm, that sounds odd. I only have version 1 Pis so cannot be 100% sure but I have tested with both the older Wheezy versions of Raspbian and the latest Jessie.

Does it return back to the shell prompt after 5 seconds (as it should)?

Which OS and version you have (what does 'uname -a' output)?
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by itsagoodquestion » Tue Mar 08, 2016 10:04 pm
Hey there, thanks for your response.

Code: Select all
$ uname -a
Linux raspberrypi 4.1.17-v7+ #838 SMP Tue Feb 9 13:15:09 GMT 2016 armv7l GNU/Linux


The code from your tutorial #2 works as intended, but it does not return my desktop me. All the other codes I tried give me a black screen. So anytime after I run it, I have to reboot the machine via serial to tty cable to get display back. I've also tried running fbset w/depth-16 set before and that doesn't work either.

I haven't had much time lately to troubleshoot it I was just hoping you knew a quick fix, but I look very forward to getting this code working when I get more time :D :D :D
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm
by -rst- » Wed Mar 09, 2016 9:33 am
[quote="itsagoodquestion"... So anytime after I run it, I have to reboot the machine via serial to tty cable to get display back. I've also tried running fbset w/depth-16 set before and that doesn't work either. ...[/quote]

One trick that might help in these situations (obviously if it is not a complete lock up) is the use of the virtual consoles: hit Ctrl+Alt+F2 to get to the second console, login and reboot from there (of course the serial tty or a ssh session is about the same but this does not require another computer).
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by ciel77 » Fri Jun 09, 2017 11:11 pm
Great post! Thank you so much for writing this up.
I have no problem running switch page using your "ioctl version", however, I got "ioctl_set_msg failed:-1" when running "mailbox version". I am using raspberry pi 3 B+ with jessie 8. I need to change major device number in vcio.h from 100 to 248. But still cannot figuring out what's causing "ioctl_set_msg failed:-1". I have been searching around but couldn't find a solution. Any thoughts on what I am missing here? Thank you.
Posts: 6
Joined: Fri Jun 09, 2017 11:05 pm
by ciel77 » Fri Jun 09, 2017 11:13 pm
Great post! Thank you so much for writing this up.
I have no problem running switch page using "ioctl version", however, I got "ioctl_set_msg failed:-1" when running "mailbox version". I am using raspberry pi 3 B+ with jessie 8. I need to change major device number in vcio.h from 100 to 248. But still cannot figuring out what's causing "ioctl_set_msg failed:-1". I have been searching around but couldn't find a solution. Any thoughts on what I am missing here? Thank you.
Posts: 6
Joined: Fri Jun 09, 2017 11:05 pm
by -rst- » Mon Jun 12, 2017 5:03 pm
The mailbox interface seems to have changed at some point and will likely not work anymore (as I think I pointed out in one of the posts).
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by ciel77 » Tue Jun 13, 2017 2:27 am
-rst- wrote:The mailbox interface seems to have changed at some point and will likely not work anymore (as I think I pointed out in one of the posts).


Thank you for the reply. Based on https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface#set-virtual-offset, I modified the code as below and but it's not working:
Code: Select all
   p[i++] = 0; // size
   p[i++] = 0x00000000; // process request

   p[i++] = 0x00048009; // set virtual offset
   p[i++] = 0x00000008;
   p[i++] = 0x00000008;
   p[i++] = *x; // value buffer
   p[i++] = *y; // value buffer 2


Am I using the mailbox interface wrong?
Posts: 6
Joined: Fri Jun 09, 2017 11:05 pm