Sign in to follow this  
Followers 0
matwachich

C callback function passing a struct, possible?

5 posts in this topic

Hi every body!

I'm actually trying to make a wrapper for Chipmunk Physics library, it's an OpenSource 2D rigide bodies physics library, and I have a problem:

There is a callback function passing a structure (cpVect), and I don't know if there is a trick to be able to use it.

Here is the declaration of the callback

;~ typedef void(*   cpSpaceNearestPointQueryFunc )(cpShape *shape, cpFloat distance, cpVect point, void *data)
;~      Nearest point query callback function type.

Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think you'll need DllCallBackRegister but I'm not entirely sure.

Edit: I just read that DllCallBackRegister can't handle structs. Sorries.

Edited by LaCastiglione

Share this post


Link to post
Share on other sites

Thanks for the answer!

It is the probleme: DllCallBackRegister can't handle structs.

So, is there any other trick???

Share this post


Link to post
Share on other sites

Did you try using a ptr and pulling the data out from that?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

No, didn't tried yet.

I will try this, and I had another idea, gonna tell you if it works:

Knowing that a cpVect structure is "double x; double y", I will try this:

;~ typedef void(*   cpSpaceNearestPointQueryFunc )(cpShape *shape, cpFloat distance, cpVect point, void *data)
DllCallbackRegister("none:cdecl", "ptr;double;double;double;int", "_Function")

gonna see!

PS: I have not tried yet cause I didn't wrapped enough functions yet to be able to run a test

Edited by matwachich

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0