19 #ifndef GL_THREAD_CHECK_H
20 #define GL_THREAD_CHECK_H
25 #include "../threads/thread.h"
26 #include "../logging.h"
31 public std::runtime_error {
35 std::runtime_error(
"Attempted to call OpenGL from the wrong thread") {}
40 extern std::shared_ptr<GLThreadCheck> GL_thread;
48 static void clean_up() {
54 static bool is_current() {
59 return GL_thread->do_check(
false);
62 thread::ThreadID thread_id()
const {
63 return render_thread_id_;
69 bool do_check(
bool raise=
true) {
71 if(thread::this_thread_id() != render_thread_id_) {
83 thread::ThreadID render_thread_id_;
88 #endif // GL_THREAD_CHECK_H