Advertisement Jump to content
Sign in to follow this  

GLFW Callback Trouble

This topic is 3832 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 have a class that includes all my GLFW callback functions, but I get an error when I try to set the callbacks. The error is: "argument of type `void (dave::gui::Root::)(int, int)' does not match `void*'" It seems that GLFW callbacks must be in the global namespace. Is there any way around this so that I don't have to have these callbacks in the global namespace? The first solution I came up with was to have the callbacks in the global namespace, and then making the original callbacks in my class public, and then calling those from the global callback functions. This is very messy to me and I'd like to avoid this "solution" if possible. Any ideas are appreciated. Thanks.

Share this post

Link to post
Share on other sites
They do not need to be in the global namespace, the compiler just needs to know their location on compile time. That means they will have to be static functions within the class, usually callbacks over a void* to pass the class in, like this.

class MyClass
static void myCallback(void*);

void myCallback();

void MyClass::myCallback(void* data)
MyClass* my_class = reinterpret_cast<MyClas*>(data);

I do not really know what GLFW offers though.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!