Sign in to follow this  

GLFW input callback functions problems

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

This topic is 4663 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this