Hi , I have an issue developing a multi window app in OF
This app is a ‘live video’ application, by that I mean I needed to make sure that the glfw window could not be accidentally closed. I achieved that by overriding glfwSetWindowCloseCallback
void ofApp::windowCloseCallBack(GLFWwindow * _window) {
glfwSetWindowShouldClose(_window, false);
}
glfwSetWindowCloseCallback(glfw_window, windowCloseCallBack);
I does what I need, I then will be able to close the app as I wish )
But, to go a little further I tried to use :
glfwSetWindowUserPointer(glfw_window, this);
The goal is to have access to the ofApp inside the callback function.
I compiles fine, but the app crashes after 5 seconds of a blank window every time.
I had the feeling this ‘user pointer’ has already been set by OF
so I did :
void ofApp::windowCloseCallBack(GLFWwindow * _window)
{
ofApp * user_ptr = static_cast<ofApp*>(glfwGetWindowUserPointer(_window));
std::cout << user_ptr->proc_width <<std::endl;
glfwSetWindowShouldClose(_window, false);
}
And it sort of works … the static cast is successful but the cout line prints some uninitialized values.
I am a little out of my depth here.
Am I going in the right direction ?