How to run c code(on codeblocks) without desktop on raspberry?(Like work of omxplayer)

171 Views Asked by At

Sorry my bad English. I work 3d shape with opengl on raspberry pi3(debian) for a while. I want to run my code don't use on desktop(or window). I searched but puzzled my mind. In a nutshell I want to run my code as well as in image below.

enter image description here

When I searched this topic, I have seen about EGL library but I don't know if I can use this.

If you used OpenMAX library before you know openmax doesn't use window. All image or video can run on console mode. You don't need any dosktop. I wonder this Is there a way I can use Opengl in this way ?(Can Opengl run like OpenMAX library or not) If there is any way How should I build my code ? I want render my image without desktop. I want use console mode.

Thanks your time. Best Regards.

3

There are 3 best solutions below

2
On

The most straightforward solution would be to just create a fullscreen window, that has no border and no decorations (titlebar, buttons, etc.). If you want actual graphic output, there's nothing wrong with using X11. Despite some hearsay thrown around on the Internet the Xorg X11 servers are actually pretty lightweight.

If you really want to go without X11, then you should look at things like the kmscube demo https://cgit.freedesktop.org/mesa/kmscube/tree/ which does OpenGL directly to the display, without a graphics server or windowing system in between.

If you want it to be a little more abstracted, then have a look at how Wayland compositors talk to the display. The developers of the Sway Wayland compositor developed a nice abstraction library for this: https://github.com/swaywm/wlroots

0
On

You need to start display server first. What you need could work with "xinit" which would manualy start xorg server, after that I suspect you should start "openbox" which is window manager. This way your desktop application should run as is, no changes needed.

Best practice is to create shell script for starting your application which could look like this:

set -e 
xset s off
xset -dpms
xset s noblank
openbox &
cd /home/your_applicaton_directory
your_executable 2>/dev/null >/dev/null

Save this script and mark it executable whith

chmod +x 

Then try to run this:

xinit /full_path_to_above_script

Hope this helps a bit... :)

1
On

Qt has a platform backend called eglfs, which lets your application run fullscreen on a single screen by using EGL and kms with very little overhead. Should work nicely with whatever OpenGL stuff you want to do.

You would just program a Qt application like normal, and launch it with ./myapp -platform eglfs from a tty.

http://doc.qt.io/qt-5/embedded-linux.html#eglfs