GLUT Celestia C++ challengeing trouble
Posted: 05.03.2006, 22:47
Hi all, I?€™m asking for help.
After a long time I'm dealing with GLUT - Celestia.
I would like to use freeglut and I would like to create a C++ wrapper for its initialization.
I?€™ve created the following objects:
I?€™m Using Visual Studio and the error messages that the compiler returns are similar to the following:
c:\CVS_sandbox\celestia_dev\src\glutapp.cpp(196): error C2664: "glutDisplayFunc": impossible to convert parameter 1 from "void (__cdecl GLUTApp::* )(void)" to "void (__cdecl *)(void)"
Browsing the internet I've found the reason. A direct assignment to a function pointer using a pointer to a method is impossible. However since the problem is very complex I did not found understandable suggestions for a workaround.
Can please someone give a suggestion?
Kind regards!
After a long time I'm dealing with GLUT - Celestia.
I would like to use freeglut and I would like to create a C++ wrapper for its initialization.
I?€™ve created the following objects:
Code: Select all
Class App
{
public:
App();
virtual void __cdecl displayFn(void);
virtual void __cdecl keyFn(unsighed char, int, int);
...
private:
virtual void init();
...
}
Class GLUTApp: public App
{
...
private:
void init(); //method override
...
}
// implementation
void GLUTApp::init()
{
// inherited
App::init();
...
// Create the window
glutInitWindowPosition(0, 0);
glutInitWindowSize(screenW, screenH);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutInit(&argc, argv);
hWnd = glutCreateWindow("FreeGLUT Celestia");
// callbacks
glutDisplayFunc(&uiGLUTApp::displayFn); // * Error !!!!!!
glutKeyboardFunc(&uiGLUTApp::keyFn); // * Error !!!!!!
glutMouseFunc(&uiGLUTApp::mouseFn); // * Error !!!!!!
glutMotionFunc(&uiGLUTApp::dragFn); // * Error !!!!!!
glutPassiveMotionFunc(&uiGLUTApp::motionFn); // * Error !!!!!!
...
}
I?€™m Using Visual Studio and the error messages that the compiler returns are similar to the following:
c:\CVS_sandbox\celestia_dev\src\glutapp.cpp(196): error C2664: "glutDisplayFunc": impossible to convert parameter 1 from "void (__cdecl GLUTApp::* )(void)" to "void (__cdecl *)(void)"
Browsing the internet I've found the reason. A direct assignment to a function pointer using a pointer to a method is impossible. However since the problem is very complex I did not found understandable suggestions for a workaround.
Can please someone give a suggestion?
Kind regards!