I have an class with instance functions (or methods?). From within an instance, I try to pass pointers to those functions to a library. The library expects static functions
It is possible and apparently safe to use a file scoped static variable pointing to your GlutInstance (static function + static data, like mentioned in another answer).
static GlutController* s_this;
static void s_OnChangeSize(int w, int h) { s_this->OnChangeSize(w, h); }
GlutController::GlutController (int argc, char **argv) {
s_this = this;
glutSpecialFunc(s_OnSpecialKeys);
}
GlutController::~GlutController() { s_this= 0; }
void GlutController::OnChangeSize(int w, int h) { /* non-static stuff */ }
s_this
is only visible in the local file, e.g. not visible to any code that invokes the GlutController constructor from another file.