使用eglInitialize进行分段错误/使用不带X11的OpenGL

Mic*_*ich 6 linux x11 opengl egl

我试图使用OpenGL并将输出直接写入Imx6处理器(cubox)上的Framebuffer.原因是我试图避免使用X11

我使用了https://github.com/benosteen/opengles-book-sa​​mples/blob/master/Raspi/Chapter_2/Hello_Triangle/Hello_Triangle.c中的示例应用程序.

我将代码修改为不包含任何X11头文件或Window创建函数,我替换了surface = eglCreatePixmapSurface(display,config,(EGLNativePixmapType)Hwnd,NULL); with surface = eglCreatePbufferSurface(display,config,surfaceAttribs);

然后我使用glReadPixels(..)将OpenGl像素直接输出到帧缓冲区

当我使用VisualGDB运行应用程序时,应用程序运行良好,并通过写入/ dev/fb0直接在屏幕上显示输出

但是,当我从控制台运行时,使用./OpenGL_Test_IMX我收到以下错误:

The framebuffer device was opened successfully.
The framebuffer device was opened successfully.
1920x1200, 32bpp
The framebuffer device was mapped to memory successfully.
libEGL warning: DRI2: xcb_connect failed
libEGL warning: DRI2: xcb_connect failed
libEGL warning: GLX: XOpenDisplay failed
Segmentation fault
Run Code Online (Sandbox Code Playgroud)

我的Egl初始化代码如下所示.我拿出错误检查以缩短时间.

代码在eglInitialize(display,&majorVersion,&minorVersion)上失败.分段错误是eglGetError()的输出

EGLBoolean CreateEGLContext(EGLNativeWindowType hWnd, EGLDisplay* eglDisplay,
EGLContext* eglContext, EGLSurface* eglSurface,
EGLint attribList[])
{
     EGLint numConfigs;
     EGLint majorVersion;
     EGLint minorVersion;
     EGLDisplay display;
     EGLContext context;
     EGLSurface surface;
     EGLConfig config;
     EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };

     // Get Display
     display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

     // Initialize EGL
     if (!eglInitialize(display, &majorVersion, &minorVersion))
     {
        printf(eglGetError());
        return EGL_FALSE;
     }

     // Get configs
     eglGetConfigs(display, NULL, 0, &numConfigs)
     // Choose config
     eglChooseConfig(display, attribList, &config, 1, &numConfigs)

     int surfaceAttribs[] = {
         EGL_WIDTH, 1900,
         EGL_HEIGHT, 1088,
         EGL_NONE
     };
     surface = eglCreatePbufferSurface(display, config, surfaceAttribs);
     //surface = eglCreatePixmapSurface(display, config, (EGLNativePixmapType)Hwnd, NULL);

     // Create a GL context
     context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);

     // Make the context current
     eglMakeCurrent(display, surface, surface, context)

     *eglDisplay = display;
     *eglSurface = surface;
     *eglContext = context;
     return EGL_TRUE;
 }
Run Code Online (Sandbox Code Playgroud)

我的最后一个问题是运行OpenGL是否需要EGL,或者是否可以运行OpenGL并将其写入内存位置?

如果不能在没有X11的情况下运行,我怎样才能启动最小值(例如:Xorg服务器)并让它作为上下文使用?任何人都可以提供一些帮助(或命令)如何使用X11上下文启动程序?

也许我没有正确启动应用程序?例如,我是否需要事先启动EGL服务器?

最后,当我从VisualGDB http://pastebin.com/t8hgWthx启动应用程序时,这是我所有正在运行的进程的 一个pastebin,当我没有时,这是一个pastebin,http://pastebin.com/PvdpQqT8 我注意到一些差异但是我没有看到使用X11上下文启动应用程序所需的任何具体内容.