Menu

Callback Member Functions

Using GLFW
Anonymous
2004-05-15
2004-05-21
  • Anonymous

    Anonymous - 2004-05-15

    I tried to make a member function of one of my classes into a callback function, but it gave me an error. Is there a way to have a callback member function?

     
    • Anonymous

      Anonymous - 2004-05-17

      Make the member function a static member function & it should work.

       
    • Anonymous

      Anonymous - 2004-05-17

      That will work currently. But in the future I may decide to have multiple instantiations of this class. In that case, I will want to be able to control which object's member function is set as the callback function.

      Also I don't like static members because they are too global...

       
    • Anonymous

      Anonymous - 2004-05-17

      That will work currently. But in the future I may decide to have multiple instantiations of this class. In that case, I will want to be able to control which object's member function is set as the callback function.

      Also I don't like static members because they are too global compared to non-static members. I don't need or want my callback functions to be that global.

       
    • Nobody/Anonymous

      Look into functors, it allows you to link a callback function to any member function.

       
    • Andy Friesen

      Andy Friesen - 2004-05-20

      I would like to see this supported as well.

      All that's really required is that every callback have accompanying user data that's big enough for a pointer.  From there, it's easy enough to write a C stub that relays to the proper method.

       
      • Marcus Geelnard

        Marcus Geelnard - 2004-05-21

        Hi! This [user data in callbacks] is actually a planned feature. It may not appear anytime soon since it would wreck the 2.x API, but I realize that it's an important feature, especially when/if support for multiple windows appear (you may want to use the same callback for multiple windows).