Jump to content
  • Advertisement
Sign in to follow this  

C++ Function Pointers

This topic is 4169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a huge problem trying to create a GLUT class. The problem is when it comes to setting up the callback funtions in glut. Below is a demo class that illustrates the problem: class glutTest { public: glutTest(int argc, char** argv) { // CALLBACK glutDisplayFunc(&glutTest::drawGLScene); } private: void drawGLScene(void){} }; This will not compile but dies with the following error: 'glutDisplayFunc' : cannot convert parameter 1 from 'void (__thiscall glutTest::* )(void)' to 'void (__cdecl *)(void)' If i remove the class operator and have it as follows : glutDisplayFunc(drawGLScene); i get this error: 'glutTest::drawGLScene': function call missing argument list; use '&glutTest::drawGLScene' to create a pointer to member So i've checked almost all my C++ reference books, none of them had any kind of comprehensive section on function pointers or about converting/casting them. Even googling didnt help. I'm guessing i somehow have to cast a function pointer to the right type? Can anyone help?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!