aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/application.cpp
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-09-14 22:18:22 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:41:05 +0100
commit3d85a593bf0812f50f08f4852fae00fdd16fffd8 (patch)
tree48fa5fd4bd08b75fa9558e5e63e3cf083a2b8f19 /src/menu/application.cpp
parent82306827bd8c8b7b0a667df48bd95f5c2948c690 (diff)
downloadusdx-3d85a593bf0812f50f08f4852fae00fdd16fffd8.tar.gz
usdx-3d85a593bf0812f50f08f4852fae00fdd16fffd8.tar.xz
usdx-3d85a593bf0812f50f08f4852fae00fdd16fffd8.zip
menu/application: add possibility to query if ogl thread
opengl calls should only executed in the thread, that created the opengl context. To query whether the current thread is the opengl thread, the application class stores the current thread id of the opengl thread after initializing opengl.
Diffstat (limited to 'src/menu/application.cpp')
-rw-r--r--src/menu/application.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/menu/application.cpp b/src/menu/application.cpp
index 1e82b6e2..b8392802 100644
--- a/src/menu/application.cpp
+++ b/src/menu/application.cpp
@@ -80,6 +80,11 @@ namespace usdx
return get_instance()->config;
}
+ bool Application::is_gl_thread(void)
+ {
+ return boost::this_thread::get_id() == get_instance()->gl_thread;
+ }
+
void Application::main_loop(SDL_Surface* display)
{
SDL_Event event;
@@ -157,6 +162,9 @@ namespace usdx
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
+ // save current thread, to be able to detect whether some method is
+ // called from the thread owning the OpenGL contect
+ gl_thread = boost::this_thread::get_id();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();