There is a subtle threading issue happening. For some unkown reason, the EGL context goes bad after waiting on a future in the main thread - the EGL context was made current in the main thread and should remain so.
Possibly a TLS issue.
....
while (running)
{
//EGL context is good here - all gl calls made here work fine. frame_written_future.wait();
//EGL context is not valid here anymore all gl calls fail after this wait
auto format = read_pixels(frame_size, frame_data.data()); frame_written_future = write_frame_to_file(frame_data, frame_number, format);
There is a subtle threading issue happening. For some unkown reason, the EGL context goes bad after waiting on a future in the main thread - the EGL context was made current in the main thread and should remain so.
Possibly a TLS issue.
....
frame_ written_ future. wait(); frame_size, frame_data.data());
frame_ written_ future = write_frame_ to_file( frame_data, frame_number, format);
while (running)
{
//EGL context is good here - all gl calls made here work fine.
//EGL context is not valid here anymore all gl calls fail after this wait
auto format = read_pixels(
}