glfwSetKeyCallback() question

nobody wrote on Monday, August 28, 2006:


Hopefully this isn’t too much of a stupid question, but is it possible to set the callback method to be a method within a class

eg: glfwSetKeyCallback(somefancyclass->KeyHandle)

I get errors when doing it (not at the machine to see the exact msg).

Just want to know if it’s just my noobness or if its not possible at all.


melekor wrote on Monday, August 28, 2006:

This isn’t possible at all with the current design. Think about it: How would GLFW know which instance of somefancyclass to call KeyHandle on?


The callback must be a "regular function" i.e. without an implicit "this" parameter. If you want the callback function to be in a class, then it must be declared as static.