+
+ // Augh :-)
+ mutex mu;
+ condition_variable done_cv;
+ bool done = false;
+
+ post_to_main_thread([this, &frame, len, &done, &mu, &done_cv]{
+ makeCurrent();
+ glCreateBuffers(1, &frame->pbo);
+ glNamedBufferStorage(frame->pbo, len, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
+ frame->data = (uint8_t *)glMapNamedBufferRange(frame->pbo, 0, len, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT);
+ doneCurrent();
+
+ lock_guard lock(mu);
+ done = true;
+ done_cv.notify_all();
+ });
+ {
+ unique_lock lock(mu);
+ done_cv.wait(lock, [&done]{ return done; });
+ }