简体   繁体   English

在无头服务器或虚拟控制台上使用EGL

[英]Using EGL on headless server or virtual console

I'm trying to use EGL in an environment without an X server. 我正在尝试在没有X服务器的环境中使用EGL。 For testing purposes, I created a simple program that tries to get the EGL version: 出于测试目的,我创建了一个试图获取EGL版本的简单程序:

$ cat version.c
#include <stdio.h>

#include <EGL/egl.h>

int main() {
  EGLDisplay eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);

  EGLint major;
  EGLint minor;

  EGLBoolean eglInitialized = eglInitialize(eglDisplay, &major, &minor);

  printf("%d %d %d\n", major, minor, eglInitialized);


  return 0;
}

$ gcc version.c -lEGL

When I run this on a standard Ubuntu machine, it runs just fine and prints 1 4 1 meaning that EGL is version 1.4 and the display was successfully initialized. 当我在标准的Ubuntu机器上运行它时,它运行得很好并打印1 4 1意味着EGL是版本1.4并且显示器已成功初始化。

To emulate the server environment on which I eventually want to run, I switch to a virtual console with Ctrl + Alt + F1 , but now it fails: 为了模拟我最终想要运行的服务器环境,我使用Ctrl + Alt + F1切换到虚拟控制台,但现在它失败了:

$ ./a.out
libEGL warning: DRI3: xcb_connect failed
libEGL warning: DRI2: xcb_connect failed
libEGL warning: DRI2: xcb_connect failed
0 4196000 0

The same thing happens on the remote server. 远程服务器上也发生了同样的事情。

I am not an expert here, but I think I know enough to answer this question sufficiently (though by now you have probably solved it long ago). 我不是这里的专家,但我认为我已经足够充分地回答这个问题(尽管现在你可能已经解决了很久以前)。 You are trying to use the default display, which is X11 on your system. 您正在尝试使用默认显示,即系统上的X11。 For headless you probably want to use gbm, assuming you are on a system using a relatively recent Mesa GL library and a kernel (Linux or other) which supports that. 对于无头,你可能想要使用gbm,假设你使用的是一个使用相对较新的Mesa GL库和支持它的内核(Linux或其他)的系统。

See the Mesa eglinfo demo[1] for an example, and eglkms[2] for an example of rendering. 有关示例,请参阅Mesa eglinfo演示[1],有关渲染的示例,请参阅eglkms [2]。 You would want to leave out the bits which set the mode and create and display the frame buffer of course, and you might want to use /dev/dri/renderD128 instead of /dev/dri/card0. 您可能希望省略设置模式的位并创建和显示帧缓冲区,您可能希望使用/ dev / dri / renderD128而不是/ dev / dri / card0。

[1] https://cgit.freedesktop.org/mesa/demos/tree/src/egl/opengl/eglinfo.c [2] https://cgit.freedesktop.org/mesa/demos/tree/src/egl/opengl/eglkms.c [1] https://cgit.freedesktop.org/mesa/demos/tree/src/egl/opengl/eglinfo.c [2] https://cgit.freedesktop.org/mesa/demos/tree/src/egl /opengl/eglkms.c

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

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