Better callbacks
This commit is contained in:
@@ -202,37 +202,4 @@ void OGLWindow::setTitle(const std::string& name) {
|
||||
glfwSetWindowTitle(_window_ptr, _title.c_str());
|
||||
}
|
||||
|
||||
template<>
|
||||
void OGLWindow::setCallback<OGLWindow::KEY>(std::function<void(OGLWindow*, int, int, int, int)> callback) {
|
||||
CheckForMainThread();
|
||||
auto tmp = makeCurrent();
|
||||
static auto this_ptr = this;
|
||||
static auto tmp_callback = callback;
|
||||
glfwSetKeyCallback(_window_ptr, [](GLFWwindow*, int a, int b, int c, int d){
|
||||
tmp_callback(this_ptr, a, b, c, d);
|
||||
});
|
||||
}
|
||||
|
||||
template<>
|
||||
void OGLWindow::setCallback<OGLWindow::MOUSE_BUTTON>(std::function<void(OGLWindow*, int, int, int)> callback) {
|
||||
CheckForMainThread();
|
||||
auto tmp = makeCurrent();
|
||||
static auto this_ptr = this;
|
||||
static auto tmp_callback = callback;
|
||||
glfwSetMouseButtonCallback(_window_ptr, [](GLFWwindow*, int a, int b, int c){
|
||||
tmp_callback(this_ptr, a, b, c);
|
||||
});
|
||||
}
|
||||
|
||||
template<>
|
||||
void OGLWindow::setCallback<OGLWindow::CURSOR_POS>(std::function<void(OGLWindow*, double, double)> callback) {
|
||||
CheckForMainThread();
|
||||
auto tmp = makeCurrent();
|
||||
static auto this_ptr = this;
|
||||
static auto tmp_callback = callback;
|
||||
glfwSetCursorPosCallback(_window_ptr, [](GLFWwindow*, double a, double b){
|
||||
tmp_callback(this_ptr, a, b);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user