-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to pass two objects to ImDrawList::AddCallback() #4770
Comments
Your |
I think you were right, I've only had to put the callback in a static class method and the |
Usually you’d want to store your own data stream to carry data required by callbacks, and then in the callback you may only store e.g an index/offset into that stream.
I suppose it may be helpful to add an opaque user data only ImVector inside ImDrawList instances to made it easier (been asked for that before).
|
Now that I think about it, I could've sent directly the id of the shader and that of the texture (not sure if it would've made a difference). I'm just too lazy to memorize opengl functions, that's why I prefer to use my own wrapper classes. |
FYI this has been simplified with 98d52b7, |
As a follow-up to #4748, I've managed to use a custom shader to set a rectangle to a different color as explained in the example shown in #4174. While doing this I've sent my shader class instance as a 2nd argument to
ImDrawList::AddCallback()
and it worked fine.Now I also want to send the texture to the same method in order to modify it. However, when I combine the shader program instance and the texture either in the same
struct
or in anstd::pair
and set AddCallback's 2nd argument to a pointer to this structure, I get a segmentation fault. I verified inside the lambda function that neither the program nor the texture were set (their ids were random), which wasn't the case when only the program shader instance was sent to the lambda function (via AddCallback).Anyone familiar with
ImDrawList
has an explanation for why only a single variable could be sent as AddCallback's first argument? or maybe I should proceed differently?The text was updated successfully, but these errors were encountered: