how does OF manage glut callback with class members?

hi i just learned that glut and c++ are no really close friends:
glut does not understand callbacks (function pointer) to a class method.

but walking a bit in ofAppGlutWindow.h i see something that seems a callbacks to a class method…
wht is that?

it’s static methods which are methods that are owned by the class not by a particular instance so you can use them as if they were functions when passing a function pointer. the idea is that an instance function is actually translated by the compiler from something like:




so when you try to pass it as a function pointer to something that is expecting a function with arg1 and arg2 it’s not going to work. as static functions are not asociated to any particular instance, you can pass them as if they were normal functions.

then you cannot access any instance variables from a static function so you need to keep a pointer to the instance as it’s done if ofAppGlutWindow. the only advantage is that being members of the class you have access to the private memebers

ohu ‘static’ was declared only in .h, i was reading only .cpp
i’m not used to header files yet, thanks!