Offscreen rendering

Render and capture offscreen?

I am trying to render to an offscreen buffer for automated testing purposes to save to a video file. This diff from Sept 2019 adds offscreen rendering. It looks like exactly what I’m looking for, but I’m having trouble getting it to work. How do I enable it?

what I have tried

  • I was able to modify CMakeLists.txt (set VIDEO_OFFSCREEN to ON), run cmake, then build libSDL2. The SDL objects it built had offscreen enabled, but after running SDL_VideoInit("offscreen"), I ended up with the error Could not find a valid EGL device to initialize (from SDL_egl.c).
  • Before using SDL, I was able to successfully use offscreen mesa to render offscreen, so I know this is possible. However, I need to use SDL, but can’t get it working. I can’t find any documentation regarding offscreen.

Hmmm not sure off the top of my head. I would double check a few of the tests are working, mainly try to run these two tests:


If testgles2.c works, but testoffscreen fails then may need to dig a little bit into the loop to see where its failing. ie. Is it finding devices to iterate on? If so, is it failing to eglInit? If thats the case you can try to dump what the eglGetError is there and see if you can figure some more out around there!

Is it finding devices to iterate on?

No it’s not. I put some print statements in, and num_egl_devices is zero after querying devices.

Looks like I don’t have any egl devices because I did not compile mesa with egl or dri. I don’t think this will work on my setup because I’m not running with a gpu or X windowing.