I'm using MSVC++ and freeglut in order to use openGL. Now, I have a class called Camera
, which is pretty simple, but it also holds the function for the reshaping of my window.
My question is: how can I set glutReshapeFunc(void (*callback)(int,int))
to my function in my camera?
I have the following code, which won't work, because of a compiler error:
int main(int argc, char **argv)
{
Camera *camera = new Camera();
glutReshapeFunc(camera->ReshapeCamera);
}
and my Camera class looks like this in Camera.h:
class Camera
{
public:
Camera(void);
~Camera(void);
void ReshapeCamera(int width, int height);
};
Maybe this is just a more general callback question, but the only thing I found on the internet was creating some wrapper class around the callback. But it doesn't look like this should be so hard. Thanks in advance.
Error 1 error C2664: 'glutReshapeFunc' : cannot convert parameter 1 from 'void (__thiscall Camera::* )(int,int)' to 'void (__cdecl *)(int,int)'
. And adding an explicit __cdecl gives a warning about theCamera::
-part. – Cherisecherish