void example_thread_main(ExampleThreadData& data) { const ExampleThreadData::Common& common = data.common(); const x11::ScreenNames& sn = common.screen_names; // pick one of the available display screens // for this thread std::size_t disp_idx = data.thread_index; if(sn.size() > 1) ++disp_idx; disp_idx %= sn.size(); // open the picked display x11::Display display(sn[disp_idx].c_str()); // initialize the pixelmaps and the sharing context x11::Pixmap xpm(display, common.vi, 8, 8); glx::Pixmap gpm(display, common.vi, xpm); glx::Context ctx(display, common.fbc, common.ctx, 3, 3); ctx.MakeCurrent(gpm); // signal that the context is created common.thread_ready.Signal(); // wait for the example to be created // in the main thread common.master_ready.Wait(); // if something failed - quit if(common.failure) { common.thread_ready.Signal(); return; } else { try { assert(common.example); // call makeExampleThread std::unique_ptr<ExampleThread> example_thread( makeExampleThread( *common.example, data.thread_index, common.example_params ) ); data.example_thread = example_thread.get(); // signal that it is created common.thread_ready.Signal(); // wait for the main thread common.master_ready.Wait(); // if something failed - quit if(common.failure) return; // start rendering while(!common.done && !common.failure) { example_thread->Render(common.clock); glFlush(); } data.example_thread = nullptr; } catch(...) { data.example_thread = nullptr; throw; } } ctx.Release(display); }
void example_thread_main(ExampleThreadData& data) { const ExampleThreadData::Common& common = data.common(); eglplus::Display display; eglplus::Surface surface = eglplus::Surface::Pbuffer( display, common.config, common.surface_attribs.Get() ); eglplus::BindAPI(eglplus::RenderingAPI::OpenGL); eglplus::Context context( display, common.config, common.context, common.context_attribs.Get() ); context.MakeCurrent(surface); // signal that the context is created common.thread_ready.Signal(); // wait for the example to be created // in the main thread common.master_ready.Wait(); // if something failed - quit if(common.failure) { common.thread_ready.Signal(); return; } else { try { assert(common.example); // call makeExampleThread std::unique_ptr<ExampleThread> example_thread( makeExampleThread( *common.example, data.thread_index, common.example_params ) ); data.example_thread = example_thread.get(); // signal that it is created common.thread_ready.Signal(); // wait for the main thread common.master_ready.Wait(); // if something failed - quit if(common.failure) return; // start rendering while(!common.done && !common.failure) { unsigned part_no = 0; double comp = 0.0; do { comp = example_thread->RenderPart( part_no++, common.clock ); glFlush(); } while(comp < 1.0); } data.example_thread = nullptr; } catch(...) { data.example_thread = nullptr; throw; } } }