简体   繁体   English

如何在没有桌面的 raspberry 上运行 c 代码(在代码块上)?(就像 omxplayer 的工作)

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

Sorry my bad English.对不起我的英语不好。 I work 3d shape with opengl on raspberry pi3(debian) for a while.我在树莓派 pi3(debian) 上使用 opengl 处理 3d 形状有一段时间了。 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.当我搜索这个主题时,我看到了 EGL 库,但我不知道我是否可以使用它。

If you used OpenMAX library before you know openmax doesn't use window.如果您在知道 openmax 不使用窗口之前使用过 OpenMAX 库。 All image or video can run on console mode.所有图像或视频都可以在控制台模式下运行。 You don't need any dosktop.你不需要任何 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 ?我想知道有没有办法以这种方式使用 Opengl ?(Opengl 是否可以像 OpenMAX 库一样运行)如果有任何方法我应该如何构建我的代码? I want render my image without desktop.我想在没有桌面的情况下渲染我的图像。 I want use console mode.我想使用控制台模式。

Thanks your time.谢谢你的时间。 Best Regards.此致。

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.如果您想要实际的图形输出,使用 X11 没有任何问题。 Despite some hearsay thrown around on the Internet the Xorg X11 servers are actually pretty lightweight.尽管在 Internet 上有一些传闻,但 Xorg X11 服务器实际上非常轻巧。

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.如果您真的不想使用 X11,那么您应该查看 kmscube 演示https://cgit.freedesktop.org/mesa/kmscube/tree/ 之类的东西,它将 OpenGL 直接用于显示器,无需图形服务器或窗口系统之间。

If you want it to be a little more abstracted, then have a look at how Wayland compositors talk to the display.如果你想让它更抽象一点,那么看看 Wayland 合成器如何与显示对话。 The developers of the Sway Wayland compositor developed a nice abstraction library for this: https://github.com/swaywm/wlroots Sway Wayland 合成器的开发人员为此开发了一个很好的抽象库: https : //github.com/swaywm/wlroots

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.你需要的东西可以与“xinit”一起使用,它会手动启动xorg服务器,之后我怀疑你应该启动“openbox”,它是窗口管理器。 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:最佳实践是创建 shell 脚本来启动您的应用程序,它可能如下所示:

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... :)希望这个对你有帮助... :)

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. Qt 有一个名为 eglfs 的平台后端,它可以让您的应用程序通过使用 EGL 和 kms 以很少的开销在单个屏幕上全屏运行。 Should work nicely with whatever OpenGL stuff you want to do.应该可以很好地处理您想做的任何 OpenGL 内容。

You would just program a Qt application like normal, and launch it with ./myapp -platform eglfs from a tty.您只需./myapp -platform eglfs编写 Qt 应用程序,然后使用./myapp -platform eglfs从 tty 启动它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM