Give a reference of an ofApp:: member function to a library function outside ofApp::

I’m currently having the same issue as described here, same function, same library. Though I need access to member variables of my ofApp:: instance in my callback functions but I’m not sure how I would do this with either approach mentioned in that thread.

Looking into using member functions as callback just gives me headaches so far. So I’m trying the solutions mentioned in the old thread.
Making the callbacks public functions in the ofApp class doesn’t change anything for me. Which is kinda obvious given that the wiringpi function doesn’t know about my instance of ofApp. I can make it work by declaring my functions outside of the ofApp class but then I have the issue that I can’t access my member variables anymore. I can also not pass any arguments to the callbacks so I can’t pass it the class instance either. Then I would also need to declare the ofApp instance public outside the main.cpp and I end up with a solution that sound incredibly hacky and ugly to me. Could someone explain a nicer way of doing this? I’m really lost, this goes into concepts out of my scope (pun intended).

if you only need to access your ofApp a hacky solution is to use `ofGetAppPtr()->someFunction()’ from a function outside the class

1 Like

Thanks! Not a perfect solution but definitely a lot better than anything I tried so far, very handy function.