Building SDL2 with full OpenGL support against MESA buidls without GLX

Hi there,

Tittle says it all. I would like to use SDL2 on an space-constrained enviroment using the Rpi3 SOC (bcm2835 with VC4 video), and I need full OpenGL support, not only GLES.
There is no X11 server running, so I would need to get it working without X11 related dependencies. It should be perfectly possible, since full OpenGL DOES run on an EGL context, there is no need for GLX.

First of all, I build current MESA using the Meson build system like this:

meson --prefix=/usr --buildtype=plain -Db_ndebug=true -Dglvnd=false -Dplatforms=drm -Dglx=disabled -Dllvm=false -Ddri-drivers=’’ -Dvulkan-drivers=’’ -Dgallium-drivers=vc4 …

ninja -j4
sudo ninja install

As you can see, I disable both GLX and GLVND support: in that situation, MESA provides libEGL.so and libglapi.so (as opposed to libGL.so, which is GLX-only!). Since there is no dependency to GLX, there is no dependency to anything X11 either. Yet this MESA build has support for GLES1 (libGLESv1_CM.so), GLES2(libGLESv2.so) and GL(libglapi.so). Good!

However, SDL2 fails to detect OpenGL here, because for SDL2 full OpenGL = GLX, which is a WRONG assumption:

checking for kmsdrm dynamic loading support… yes
checking for OpenGL (GLX) support… no
checking for EGL support… yes
checking for OpenGL ES v1 headers… yes
checking for OpenGL ES v2 headers… yes

Looking at configure.ac, it seems to be detecting OpenGL based on the presence of GL/gl.h and GL/glx.h… and as I said, GLX is NOT the only full OpenGL API, since full OpenGL runs on EGL, too.

So, could some dev please try to replicate my MESA build and give back some advice or solution?

All in all, libSDL should NOT care about the actual OpenGL implementation, be it libGL.so or libglapi.so. libSDL should only care about libEGL.so, and accept whatever its told to have at runtime: GLES1, GLES2, full OpenGL…
Depending on GLX makes no sense at all.

1 Like