Yes and no. Some libraries indeed are restricted to running on a single thread, and I'm assuming that GLEWMX is one of those. That indeed means you shouldn't be calling it from thread 2.
Yet when you need something done by thread 1, you can't switch "the active thread". On modern computers, you have several active threads anyway, so the fact that thread 2 is active doesn't even imply that thread 1 is passive.
The correct solution is to create a threadsafe work queue for thread 1. Thread 2 can then put work in, and thread 1 picks the work up when ready. Unfortunately there's no Standard Library support for this, you'll have to cobble one together yourself. Use std::condition_variable
and .wait
in thread 1.