OpenGL on Pi Zero 2 without X/Wayland

Another step in trying to make a homebrew tablet device: getting accelerated graphics working without having to load up X or Wayland.

It's been a successful but frustrating conclusion to a day of hard work and confusion.

I had found matusnovak's triangle.c which uses EGL to render a triangle, then save it to a file.

Getting it to build it on TinyCore Linux wasn't too hard once I had found the correct tcz packages to load. It would not run though - it kept failing to create the surface.

I am not familiar with EGL, and it took a while to figure out that the graphics device was refusing to support pixel map surfaces, only window surfaces.

I found a linuxvox blog post which got me a lot further. I managed to create the window surface and render to it (I think), but I could not get it to display on the screen.

This is where my ignorance of drm really bit me. The drmModeSetCrtc function was not in drm.h and I could only find it in xf86DrmMode.h, but I thought that would make my program dependent on X11.

After much more exploring of headers, libraries and the web, I eventually figured it must be the xf86 version that I was meant to use (which, it turns out, is correct)...but it was still refusing to display the rendered triangle on the screen.

Cue more exploring of the web, including both the FreeDesktop driver documentation and the mesa documentation for the Broadcom VC4 GPU.

Then eventually, via the Raspberry Pi Forums, I came across alanbork's triangle_rpi4.c...which built and worked right out of the box.

SIGH

So I've got EGL working without X/Wayland, which is what I wanted. I've also learned a bunch about the libdrm and EGL libaries.

These are big successes for me, and I'm slowly getting over the anti-climax of spending all that time and effort only to find someone else's program that just works.

Even my first readings through alanbork's code have made me appreciate just how difficult it would have been to figure all that out for myself though...if I even would have managed it at all.

Now, I can instead concentrate on finding/designing a nice OpenGL GUI framework and a touchscreen gesture input system!