Jump to content
  • Advertisement
Sign in to follow this  
boris_tsr

GLFW input callback functions problems

This topic is 4883 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

hey, i'm making a class for my input, and i am trying to pass my function to the callback function of GLFW void GLFWCALL KeyboardCallbackFunction( int key, int action ); //this is my callbackfunction it is in a class called CInput. i have an init function (not a constructor, as i want to be able to guarantee when this gets called) which does this glfwSetKeyCallback(KeyboardCallbackFunction); when i try compiling i get this error message error: argument of type 'void (CInput::)(int,int)' does not match 'void(*)(int,int)' and i have no clue how i would get around this :/ any help would be much appreciated. p.s. i wasn't sure if this should go in beginners or not, as this is more a problem with function pointers, which i have no experience with.

Share this post


Link to post
Share on other sites
Advertisement
The callback function should be a global function, not a member function.

So this wouldn't work:

class CInput
{
void GLFWCALL KeyboardCallbackFunction( int key, int action );
};

But this would:

void GLFWCALL KeyboardCallbackFunction( int key, int action );

Share this post


Link to post
Share on other sites
yeah i thought of doing that, but would sorta screw up the way i wanted to do it, so i wanted to see if there was any other way before i took that route.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!