Is there a way to use glutTimerFunc with modern C++ classes?

Is there a way to use glutTimerFunc with modern C++ classes?

Because I run into problems in using glutTimerFunc with classes that contain non-static members. The second argument of glutTimerFunc requires either static function or a function in an instance. Both of which seem to complicate class design principles a bit.

[QUOTE=mavavilj;1292250]Is there a way to use glutTimerFunc with modern C++ classes?

Because I run into problems in using glutTimerFunc with classes that contain non-static members. The second argument of glutTimerFunc requires either static function or a function in an instance. Both of which seem to complicate class design principles a bit.[/QUOTE]

Is there any reason that you explicitly need glutTimerFunc? If not, just use the chrono lib of the STL to build your own timer function or class. If yes, I guess you can “smuggle in” everything you want by using lambdas:


MyClass myClass;

glutTimerFunc(1000,[&](int)
                           {
                                myClass.MyMemberFunction();
                           },0);                   

Don’t guarantee for code correction, since I didn’t compile it, but lambda functions do work with glutTimerFunc.

Greetings