eglGetDisplay returns EGL_NO_DISPLAY

Ok. Sorry. I’d slept and forgotten that you’d mentioned that in your original post.

I looked back at some test code where I’d done exactly that (created an EGL context using EGL_DEFAULT_DISPLAY for rendering to an on-screen PBuffer), and there’s a trick to get this to work.

The EGL/OpenGL libs you’re linked with must be able to open kernel “special” files related to the graphics driver such as /dev/nvidiactl, /dev/nvidia0, /dev/nvidia-modeset, /dev/dri/card0, and /dev/dri/renderD128. On my Linux system, these are owned by group video. So by adding my username to the video group, the EGL/OpenGL libs running as me were then able to open these files and successfully create an EGL context, even in cases where I was not the user who had started the X server.

Once your username has the required access, then this should work:

    EGLDisplay display = eglGetDisplay( EGL_DEFAULT_DISPLAY );
    assert( display != EGL_NO_DISPLAY );

    EGLint egl_major, egl_minor;
    EGLBoolean success = eglInitialize( display, &egl_major, &egl_minor );
    assert( success );

Related thread: