PDA

View Full Version : callback functions and C++



emshelly
05-16-2002, 10:28 PM
I'm writing OpenGL program in C++, and for each class, I have its specific Display, Mouse, Animate functions. But when I want to pass them into glutDisplayFunc, I get error saying "cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)'". So I asked someone, who told me that I need to make these methods into C style, but he forgot the exact way to do that, and only mentioned something about extern "C". So could anyone tell me exactly how to cast my methods as C functions so I can pass them into glutDisplayFunc?

Thanks a lot!

bakery2k
05-17-2002, 12:34 AM
Try making the functions static class members.

Jambolo
05-17-2002, 10:19 PM
... or write a non-member function that calls the member function and pass that function to glutDisplayFunc.