[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] c-callbacks
From: |
Bastian Müller |
Subject: |
[Chicken-users] c-callbacks |
Date: |
Fri, 17 Aug 2007 22:34:46 +0200 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm currently trying to interface the Open Dynamics Engine and simple
simulations are working now. Next thing is to do collision detection.
ODE uses the following callback:
typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
that I interfaced by
(define-foreign-type dNearCallback (function void (c-pointer
dGeomID dGeomID)))
For the collision detection call
void dSpaceCollide (dSpaceID space, void *data, dNearCallback
*callback);
I used
(define ode-space-collide
(foreign-lambda void "dSpaceCollide" dSpaceID c-pointer
dNearCallback))
As an example callback I defined:
(define-external (foobar (c-pointer data) (dGeomID geom1) (dGeomID
geom2)) void
(printf "collision") (newline))
Finally, I tried to do the actual call.
First, I tried:
(ode-space-collide space (null-pointer) foobar)
and during the simulation I got an
Error: bad argument count - received -2 but expected 3: error in
error
graphics.scm: 76 ode-space-collide <--
I looked into the expat egg, expat.scm, and saw it uses #$wrapper to
handle the callback, but
(ode-space-collide space (null-pointer) #$foobar)
yields
Error: (location) bad argument type - locative can not refer to
objects of this type: #<procedure (foobar data268 geom1269
geom2270)>
##sys#make-locative <--
It would be great if someone could enlighten me, so I can get this
last part of the puzzle working and actually start on the game I'm
dreaming of. :-)
Thanks in advance,
your sincerely
- --
Bastian Müller - http://turbolent.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFGxgZsUFTPKTPeTPURAuSCAJ9wvsAwElim/aYN5QoNUvGq37ccygCfcTDz
nFEH1s+qX1CdfCPYKc8BEPo=
=N2DU
-----END PGP SIGNATURE-----
- [Chicken-users] c-callbacks,
Bastian Müller <=