You can use glfwSet/GetWindowUserPointer to associate a user-defined pointer with a GLFWwindow
object. Let's say you create a GLFWwindow
pointed to by win
, and a Camera
object pointed to by cam
- setup with:
...
glfwSetWindowUserPointer(win, cam);
glfwSetCursorPosCallback(win, mouseMoveCallback);
...
Since mouseMoveCallback
is called from a C library, it has C linkage:
extern "C" void mouseMoveCallback (GLFWwindow *win, double x, double y)
{
// get the associated user-data:
Camera *cam = static_cast<Camera *>(glfwGetWindowUserPointer(win));
// manipulate the associated Camera object:
...
}