Jump to content
  • Advertisement
Sign in to follow this  
davexunit

GLFW Callback Trouble

This topic is 3734 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
Advertisement
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
{
public:
static void myCallback(void*);

private:
void myCallback();
};

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

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 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!