byte ptr to object
BlitzMax Forums/BlitzMax Programming/byte ptr to object
| ||
I getting a byte ptr returned from a C library this is one of many pointers set from max here o is an instance of a type dGeomSetData(o.geom,o) when I get the data returned Function CollisionCallback(data:Byte Ptr,g1:Int,g2:Int) how can I turn data into a type? Local o:odeent=odeent(data) gives me... Compile Error: Unable to convert from 'Byte Ptr' to '<unknown>' |
| ||
Local o:BytePtr=odeent(data) then do with it what you like, eg. Local a:Int=Int(odeent(data)) |
| ||
If you are redefining 'o' from a type to a byte ptr , how do you then access the fields in the 'o' type ? |
| ||
To convert an object o to a byte ptr p you can write:Local p:Byte Ptr = Byte Ptr oTo convert a byte ptr p to an object o you can write: Local o:Object ; ( Byte Ptr Ptr Varptr o ) [ 0 ] = p - 8So instead of: Local o:odeent=odeent(data) You could write: Local o:odeent; (Byte Ptr Ptr Varptr o)[0]=data-8 |