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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-05-17
Make the member function a static member function & it should work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
Make the member function a static member function & it should work.
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...
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.
Look into functors, it allows you to link a callback function to any member function.
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.
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).