简体   繁体   English

如何在 Linux 中没有窗口管理器的情况下使用 OpenGL?

[英]How to use OpenGL without a window manager in Linux?

I've just finished the LFS book and my Linux system is working right now.我刚刚完成了 LFS 的书,我的 Linux 系统现在正在运行。 I want to use OpenGL to display graphics on the screen, while the only installed package right now are those described on http://www.linuxfromscratch.org/lfs/view/stable/chapter03/packages.html .我想使用 OpenGL 在屏幕上显示图形,而现在唯一安装的软件包是http://www.linuxfromscratch.org/lfs/view/stable/chapter03/packages.html 上描述的那些。

I don't want to install something like Gnome, KDE or X.org.我不想安装 Gnome、KDE ​​或 X.org 之类的东西。 Instead, I want to use OpenGL directly from my software.相反,我想直接从我的软件中使用 OpenGL。 Is this possible, and how can I do this?这可能吗,我该怎么做? Or is it just as easy (I don't think so :'p) as writing an OpenGL application which runs full screen?或者它和编写一个全屏运行的 OpenGL 应用程序一样简单(我不这么认为 :'p)?

You don't have to install Gnome or KDE.您不必安装 Gnome 或 KDE。 These are used to managed windows, and you can launch graphical applications without having a window manager.这些用于管理窗口,您可以在没有窗口管理器的情况下启动图形应用程序。

Therefore, you'll have to install a X server.因此,您必须安装 X 服务器。 The X server is responsible of drawing things on your screen. X 服务器负责在屏幕上绘制内容。 Without X server, you can't launch graphical applications.没有 X 服务器,您就无法启动图形应用程序。

Once X has been installed, launch it, export your DISPLAY environment variable, and the rest is like writing an OpenGL application which runs full screen :-)一旦安装了 X,启动它,导出你的DISPLAY环境变量,剩下的就像编写一个全屏运行的 OpenGL 应用程序:-)

kmscube DRM example kmscube DRM 示例

https://github.com/robclark/kmscube https://github.com/robclark/kmscube

This is possibly the most popular demo available, it uses OpenGL and EGL.这可能是最流行的演示,它使用 OpenGL 和 EGL。

Unfortunately, the Ubuntu 18.04 package with NVIDIA proprietary drivers it does not work for me after going into Ctrl + Alt + F3:不幸的是,带有 NVIDIA 专有驱动程序的 Ubuntu 18.04 软件包在进入 Ctrl + Alt + F3 后对我不起作用:

drmModeGetResources failed: Invalid argument
failed to initialize legacy DRM

bug report: https://github.com/robclark/kmscube/issues/12错误报告: https : //github.com/robclark/kmscube/issues/12

But I did get it working on emulator .但我确实让它在 emulator 上工作。

It takes over the entire display, and shows a colorful spinning cube.它占据了整个显示器,并显示了一个彩色的旋转立方体。

You can use Pygame as well to create custom launch UI.您也可以使用 Pygame 来创建自定义启动 UI。 Also try looking at Wayland compositor as it has replaced XServer in verisons like Fedora and Ubuntu.还可以尝试查看 Wayland 合成器,因为它已经取代了 Fedora 和 Ubuntu 等版本中的 XServer。

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

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