I'm trying to use OpenGL and write the output directly to Framebuffer on an Imx6 processor (cubox) The reason for this is because I try to avoid using X11
I used the sample application from https://github.com/benosteen/opengles-book-samples/blob/master/Raspi/Chapter_2/Hello_Triangle/Hello_Triangle.c
I changed the code to not include the X11 header files or window creation functions, and I replaced surface = eglCreatePixmapSurface (display, config, (EGLNativePixmapType) Hwnd, NULL); with surface = eglCreatePbufferSurface (display, config, surfaceAttribs);
Then I output the OpenGl pixels directly to the framebuffer using glReadPixels (..)
When I launch the application using VisualGDB, the application works well, and its output is displayed directly on the screen, writing to / dev / fb 0
However, when I start from the console using. / OpenGL _Test_IMX, I get the following errors:
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
The code for my Egl initialization is shown below. I checked the error check to make it shorter.
EglInitialize code failure (display, & majorVersion, & minorVersion) Segmentation error - eglGetError () output
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; }
My last question is: do I need EGL to run OpenGL or can I run OpenGL and just write it to a memory location?
If it is not possible to run without X11, how can I only run the minimum (for example: the Xorg server) and use it as a context? Can someone provide some help (or a command) regarding how I can run the program using the X11 context?
Maybe I am not starting the application correctly? For example, do I need to start the EGL server in advance?
And finally, there is a pastebin for all my running processes when I launch the application from VisualGDB http://pastebin.com/t8hgWthx , and here is a pastebin when I am not, http://pastebin.com/PvdpQqT8 I notice some differences but I donβt see anything specific that is needed to run the application with the X11 context.