User avatar
kulminaator
Posts: 23
Joined: Mon Aug 06, 2012 8:55 am
Location: estonia

a small roundup of graphics

Sat Aug 18, 2012 6:19 am

i have done a small amount of research, over the last 2 weeks, on the possible graphics programming libraries on the raspberry pi ...

So to save the time of others, i will add my conclusions here (august 2012 state this is)

* Casual X11 stuff (2D/3D) (any graphics toolkit that comes to your head) - currently this is not accelerated 2D or 3D, very slow, puts pressure on the tiny amount of cpu power the rpi has. even slightly animated stuff brings the rpi to it's knees, movie playback on x11 surfaces brings the user interface into a halt, depending on the movie player. does provide you apis for capturing input from keyboards and mice.

* OpenGLES2 (2D/3D) - works, nice, accelerated, great, but really difficult for developers that are new to the whole opengl concept (opengles2 is purely a shader disco). if you want to make 3D stuff - this is your current choice. the demos of quake show off how much it has under the hood. more than enough from such a device. By itself is just a drawing library, handling input you have to do on your own. But as a rendering library, it is probably the most powerful tool you will have on the raspberry, ever. A lot of examples on the web (you just have to make sure you have the screen initialization of raspberry pi at the start of your code).

* DirectFB (2D) - stock version shipped with raspbian is ancient, current new branches of 1.6 are starting to show egl/gles hardware rendering support, maybe in a not too distant future this will become a real option, but currently it feels hackerisch and unstable, some work is left to be done. I did not get all their demos to work, but the ones that did work were nicely fast.

* OpenVG (2D) - hardware accelerated vector graphics, similar to DirectFB, but does not provide input device handling. Much simpler than OpenGLES, if your target is 2D development. Examples and bootstrapping are hard to come by on the internet, but luckily we have a working sample linked here in the forums in openvg topic. If you want to draw lines and boxes, some circles and have it hardware accelerated, then this is your guy for now.

* Hacking directly on the framebuffer device (2D) - if you know what you're doing, then you know what you are doing. If you dont know what you'll be doing then i would advise against (you are likely to reinvent the wheel of directfb or openvg and just be wasting your own time). Perhaps more useful for "back to the roots" style of programming experiments.

Ideas for the foundation:
* if possible, perhaps you could assist to put up some fund to support the development of accelerated 2d/3d drivers for X11, or demo out the need for a driver as a competition in some university programming context like things. we really need this to be proud of those raspberries (and 2d acceleration is even more important than 3d, for now).
* lobby the directfb package building, we could seriously use a more recent version out of the box, the current one that ships with raspbian does not offer accelerated rendering yet.
* if there's a followup device coming for the raspberry pi, please make sure the same packages of graphics would be supported :)

ps. if any typos were left in here, i'm all to blame, all sorts of comments are welcome.

abirrajkhowa
Posts: 4
Joined: Tue Jul 24, 2012 3:18 pm

Re: a small roundup of graphics

Mon Aug 20, 2012 9:35 pm

Hi ,

I am doing a project with image re-targeting on the raspberry Pi using OpenGL ES 2.0. I have come across a stage now where i have to send back data from the fragment shader to the actual application. Now i believe this is possible only with OpenCL support Or CUDA. Now we cant use CUDA because there is no Nvidia GPU. I wanted to know if OpenCL is supported by Rspberry PI.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23070
Joined: Sat Jul 30, 2011 7:41 pm

Re: a small roundup of graphics

Tue Aug 21, 2012 3:44 am

No, OpenCL isn't supported.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
kulminaator
Posts: 23
Joined: Mon Aug 06, 2012 8:55 am
Location: estonia

Re: a small roundup of graphics

Tue Aug 21, 2012 5:02 am

While slightly offtopic and hacky suggestion ... abirrajkhowa , can't you render your results as the opengl pixel array on the framebuffer and read the pixels back from there (with ReadPixels callback) ?

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: a small roundup of graphics

Tue Aug 21, 2012 5:42 pm

You forgot the SDL library (Simple Direct-media Layer).
It is a relatively platform-independant system - in that SDL exists for Win, Mac, Linux, and many other platforms including iPhone and Android... It's almost a native poke pixels at the screen system, but is capable of using some 2D accelleration if the hardware supports it. (Pi doesn't )-:

It's frequently used by some games emulators (and some games - e.g. Tuxracer and TuxPaint!)
-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
kulminaator
Posts: 23
Joined: Mon Aug 06, 2012 8:55 am
Location: estonia

Re: a small roundup of graphics

Tue Aug 21, 2012 6:55 pm

True, I skipped SDL, because as it currently stands (as you noted), at least out of stock, it's not hardware accelerated on raspberry pi, hence making it a poor option on a 700mhz armv6 cpu.

If we could get decent hardware acceleration for it, it would definitely become a good option, as it has nice i/o features & extensions for input and audio, cross platform portability too (and quite many applications that can run ontop of it).

Perhaps someone, who knows SDL well enough, can make an assessment of how much effort it would require to make it accelerated ontop of opengles2 or openvg (and when would we get the accelerated version installed from debian packages without the need for building stuff locally from source).

User avatar
ajstarks
Posts: 129
Joined: Fri Jun 22, 2012 2:14 am

Re: a small roundup of graphics

Thu Aug 23, 2012 11:53 am

Here's a link to the aforementioned thread on OpenVG: http://www.raspberrypi.org/phpBB3/viewt ... 69&t=12575

This thread discusses a high-level library written on top of OpenVG found here:

https://github.com/ajstarks/openvg

The library supports shapes (Ellipse, Circle, Rectangle, Rounded Rectangle, Polygon), Lines and Polylines, Arc, Cubic and Quadratic bezier curves, Images (JPEG), Text (supporting TrueType fonts), and transformations (Translate, Shear, and Rotate).

Screenshots are in the github repo, and also here:

http://www.flickr.com/photos/ajstarks/s ... 74/detail/

nurquhar
Posts: 16
Joined: Thu May 10, 2012 7:11 pm
Contact: Website

Re: a small roundup of graphics - cross compile

Sat Jan 12, 2013 7:26 pm

I have compiled the 3186193 example from the git hub on my RPi without problems, and it works just great. Now I want to compile it using a cross compiler but this is giving me problems.

I have succesfully setup a cross compiler toolchain as per this useful tutorial on a Kubuntu virtual m/c and hello world works fine.http://hertaville.com/2012/09/28/develo ... s-compiler

To try and get the OpenVG sample to complile I simply copied /opt/vc from the RPi to the same path on the on the Kubuntu m/c.

I then tried to use a similar gcc command to the one that worked on the RPi to get it compile. This is what I get:

Code: Select all

[email protected]:~/OpenVG/example1/3186193$ cat build
arm-linux-gnueabihf-gcc -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -L/opt/vc/lib -lGLESv2 gistfile1.c -o gistfile1

[email protected]:~/OpenVG/example1/3186193$ 
[email protected]:~/OpenVG/example1/3186193$
[email protected]:~/OpenVG/example1/3186193$ ./build
/home/nurquhar/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libEGL.so, needed by /opt/vc/lib/libGLESv2.so, not found (try using -rpath or -rpath-link)
/home/nurquhar/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libvcos.so, needed by /opt/vc/lib/libGLESv2.so, not found (try using -rpath or -rpath-link)
/home/nurquhar/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libbcm_host.so, needed by /opt/vc/lib/libGLESv2.so, not found (try using -rpath or -rpath-link)
/home/nurquhar/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libvchiq_arm.so, needed by /opt/vc/lib/libGLESv2.so, not found (try using -rpath or -rpath-link)
/tmp/ccYNiIzy.o: In function `init_ogl':
gistfile1.c:(.text+0x1c): undefined reference to `eglGetDisplay'
gistfile1.c:(.text+0x64): undefined reference to `eglInitialize'
gistfile1.c:(.text+0x90): undefined reference to `eglBindAPI'
gistfile1.c:(.text+0xb8): undefined reference to `eglChooseConfig'
gistfile1.c:(.text+0xfc): undefined reference to `eglCreateContext'
I am mistified why its all failing as all the libarys are there in /opt/vc/lib. My assumption is that /opt/vc/lib/libGLESv2.so is trying to reference other librarys like libEGL but is not finding them. Which I find strange because they are all in the path as libGLESv2. Has my approch been to simplistic, have I missed something ?

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: a small roundup of graphics

Sun Jan 13, 2013 12:36 pm

You might need to declare all those libraries on the command line (-llibEGL etc) or setup the runtime path (like the output suggests, http://en.wikipedia.org/wiki/Rpath)?
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

nurquhar
Posts: 16
Joined: Thu May 10, 2012 7:11 pm
Contact: Website

Re: a small roundup of graphics

Sun Jan 13, 2013 3:56 pm

Solved !

It seems arm-linux-gnueabihf-gcc behaves differently to gcc. It seems to need belts and braces ! I found I had to use "ldconfig" to add the path "/opt/vc/lib", something I should have done anyway. I also had to add the path to rpath-link and add the other library names.

This is my new build command :

Code: Select all

[email protected]:~/OpenVG/example1/3186193$ cat build
arm-linux-gnueabihf-gcc -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -L/opt/vc/lib -lGLESv2  -lEGL -lbcm_host -Wl,-rpath-link,/opt/vc/lib gistfile1.c -o gistfile1

[email protected]:~/OpenVG/example1/3186193$ 
[email protected]:~/OpenVG/example1/3186193$ 
[email protected]:~/OpenVG/example1/3186193$ ./build
[email protected]:~/OpenVG/example1/3186193$
For ldconfig I added the following file and ran the command.

Code: Select all

[email protected]:~/OpenVG/example1/3186193$ cat /etc/ld.so.conf.d/vc.conf
/opt/vc/lib

[email protected]:~/OpenVG/example1/3186193$ sudo ldconfig
[sudo] password for nurquhar: 
[email protected]:~/OpenVG/example1/3186193$

Return to “Graphics programming”