I\'m really stuck:
I have the mainWindow and in the main game loop I do:
// poll for input
glfwPollEvents();
this->controls->handleInput(windo
An alternative solution would be to associate a pointer to controls
to the GLFWindow
. See glfwSetWindowUserPointer.
The pointer can be retrieved at an time form the GLFWWindow
object by glfwGetWindowUserPointer. Of course the return type is void*
and has to be casted to Controls*
.
Instead of the global function or static method a Lambda expressions can be used. e.g:
glfwSetWindowUserPointer(window, this->controls);
glfwSetCursorPosCallback( window, [](GLFWwindow *window, double x, double y)
{
if (Controls *controls = static_cast(glfwGetWindowUserPointer(window)))
controls->handleMouse(window, x, y);
} );