Rendering to /dev/fb0 on Linux

Hi guys,

What I would like is - render the contents to linux framebuffer located at /dev/fb0. Do you have any clues on this?

I have explored many forums, and also the code in the official MESA repo (/src/egl/opengles1/eglfbdev.c), but so far, I am out of luck.

Is there something I am missing? The problem I am getting is - I constantly receive EGL_NO_DISPLAY. The code looks as follows (simplified for better understanding):

const char fbdev[] = “/dev/fb0”;
int fd = open(fbdev, O_RDWR);
const EGLNativeWindowType native_win = (EGLNativeWindowType) NULL;

/* make Mesa/EGL happy */
setenv(“EGL_PLATFORM”, “fbdev”, 0);

egl_dpy = eglGetDisplay((EGLNativeDisplayType)(uintptr_t)fd);
if (egl_dpy == EGL_NO_DISPLAY)
egl_fatal(“failed to get a display”);

So, my code always fails on the last IF check.

Any clue?

1 Like

hello,
I’ve also had this issue recently. Do you solve it?
I find that mesa has removed the ELS_PALTFORM_FBDEV.Could it be related to this?

hi there,
Have you checked this article: EGL Eye: OpenGL Visualization without an X Server | NVIDIA Technical Blog

  1. Make sure you enumerate the display devices and choose the right one.
    PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
    (PFNEGLQUERYDEVICESEXTPROC)
    eglGetProcAddress(“eglQueryDevicesEXT”);

    eglDpy = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT,
    eglDevs[0], 0); // I think the index may differ from platforms

  2. You have to use the pbuffer surface to swap with the display.
    // Create the pbuffer surface
    static const EGLint configAttribs[] = {
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,

    };
    static const EGLint pbufferAttribs[] = {
    EGL_WIDTH, pbufferWidth,
    EGL_HEIGHT, pbufferHeight,
    EGL_NONE,
    };
    EGLSurface eglSurf = eglCreatePbufferSurface(eglDpy, eglCfg,
    pbufferAttribs);

// Swap pbuffer surface with display
eglSwapBuffers(eglDpy, eglSurf);

I’m also a newby, the understanding may not correct though, but I hope this information could help a little bit :slight_smile:

1 Like