function as argument #133
Replies: 10 comments 7 replies
-
Assuming the The
Since the callback return value is void, that last argument to
I think what the Point_getter function is supposed to return in a single point corresponding to the index, not an array of points.
Then in the calling code,
I think that should work. /Ashok |
Beta Was this translation helpful? Give feedback.
-
As an aside, you could also pass the co-ordinates as a pointer to a native memory array via the |
Beta Was this translation helpful? Give feedback.
-
No, you do not have to declare the struct if you are only using pointers to a struct and not the struct value itself directly.
will suffice. If the Plot library is public, I can take a look as to why the callback does not work. /Ashok |
Beta Was this translation helpful? Give feedback.
-
I'll look at the ImPlot over the weekend. Regarding dummyPt not showing an error, that is because the callback has no way to return an error to the invoking script (since the return type is void). I also realized that pPoint is not a safe pointer so even if the dummyPT struct was defined, the
Ideally there should have been a I would suggest for debugging the callback, do something like
That might help debug the problem if you can see the actual error. |
Beta Was this translation helpful? Give feedback.
-
Also taking a quick look at the ImPlot functions, it appears the definition
is incorrect. The Point_getter function is defined as
I missed that in my earlier reading. That means the callback is supposed to return a pointer. I am not sure what the pointer it returns is supposed to be. You might want to check the documentation on that. I would be quite excited if you could get this ImGui integration working! /Ashok |
Beta Was this translation helpful? Give feedback.
-
And taking a closer look, the void/void* probably does not matter. The function return value is thrown away anyways. |
Beta Was this translation helpful? Give feedback.
-
Thanks , not present for the next two days , but I look at this when I come back to the office.
It's done !! My goal is to integrate ImPlot into Tk frame but Imgui is very cool ! but there is a lot of functions to write. |
Beta Was this translation helpful? Give feedback.
-
Is your repository public? /Ashok |
Beta Was this translation helpful? Give feedback.
-
You only need to share the code if resolving the Point_getter callback issue is urgent. Else it can wait. You can send it to apnmbx-wits (yahoo.com) |
Beta Was this translation helpful? Give feedback.
-
Arghh. I meant to write
and not
What you are using will also work, but I think upvar will be more efficient. Regarding /Ashok |
Beta Was this translation helpful? Give feedback.
-
Hello @apnadkarni ,
I would like to use this C function :
void Plot(const char* label_id, Point_getter getter, void* data, int count, Flags int);
Point_getter is defined like this:
typedef void *(*Point_getter)(void* data, int idx, Point *pts);
and Point is a structure like this:
My goal is to set Point when I call Plot function, finally insert a pseudo function to set coordinates of my structure Point.
So far, what I tried :
I probably don’t understand the function, but for me it’s not a callback , rather I would think a cast of a pointer to a fonction, so that I can change my values in a TCL procedure.
If callback
I don’t know if I’m going in the right direction
Beta Was this translation helpful? Give feedback.
All reactions