Importing C Functions
BlitzMax Forums/BlitzMax Programming/Importing C Functions
| ||
Hi all! I need to import c functions for a physics engine that'll work cross platform and decided upon bullet. http://bulletphysics.org/wordpress/ After downloading the sdk there's a a C-API located here src\Bullet-C-Api.h Would I just have to point to these functions in a blitzmax file as such? http://en.wikibooks.org/wiki/BlitzMax/Language/Interfacing_with_C Do I need to compile the code to a dll for windows and separate binaries for each platform? I've never really used c or c++ so some things I'm a little unsure of. Thanks a lot for your input! |
| ||
Hello, on first glance it seems that easiest way would be to create a glue.file (<filename.cpp>). In this file you would include bullet header files (btBulletDynamicsCommon.h and maybe btBulletCollisionCommon.h). The file serves as an interface between Blitzmax and Bullet core. Bullet uses objects so your glue-file would contain a function to create a relevent object and then return a pointer to it back to Blitzmax (byte ptr). After this you could pass this pointer to an another function that actually does something and inside glue file you would call objects method like: dynamicsWorld->stepSimulation(1.f/60.f,10); Here the dynamicsWorld is the name of the object and stepSimulation is it's method. -Henri |
| ||
No idea how complete it is, but someone already created a blitzmax wrapper for bullet: sedm.mod\bullet.mod https://code.google.com/p/bo3d/source/browse/trunk/sedm.mod/?r=34#sedm.mod%2Fbullet.mod |
| ||
@Henri Thanks a lot that's very helpful! @xlsior it seems this is only for windows, I need to import the functions so I can have a physics engine that works on all 3 platforms. Thanks for the help guys! |