I am working with a c library that uses setCallback
functions. These functions take a function with a fixed signature, e.g.:
int glfwSetCursorPosCallback(window, mouse_move);
Where mouse_move
has signature
void mouse_move(GLFWwindow * window, double xpos, double ypos)
But suppose mouse_move
depends on other state beyond these function arguments, like a camera
struct? In c, I would just make camera
a global variables. However, I am working in Cython
and I want to use glfwSetCursorPosCallback
without recourse to global variables, which are unpythonic and messy. If camera
is a class or instance attribute, is there any way to access it from within mouse_move
without passing it in as an argument?