Hey all,
I’m a newbie to OpenGL, but I’ve run into a fairly esoteric problem. I am trying to render an orrery (animated Solar System model), which I’ve written a class for. This Orrery class basically uses the GL and GLUT functions within its own member functions to initialize and draw itself.
My problem is: in my main OpenGL initialization function, I can’t manage to get my own display function registered via glutDisplayFunc(). The problem is that the display function (it’s called doDisplay() ) is a member function of the Orrery class, so it’s not getting passed to glutDisplayFunc() in the same way that a normal global function would.
I’m using the following code in Visual C++ 6.0:
void ( Orrery::*memPtr ) () = doDisplay;
(which sets memPtr to the address of the doDisplay() function) and:
glutDisplayFunc(memPtr );
which should set the display function correctly.
The error message I keep getting is “error C2664: ‘glutDisplayFunc’ : cannot convert parameter 1 from ‘void (__thiscall Orrery::*)(void)’ to ‘void (__cdecl *)(void)’”. In other words, glutDisplayFunc() doesn’t like the fact that it’s being passed a member function of Orrery.
I would greatly appreciate any help!