Jump to content

C callback function passing a struct, possible?


matwachich
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...