Header:
class PhysicsEngine { ...public: PhysicsEngine(); ...};static void BulletTickCallback(const btDynamicsWorld *world, btScalar timeStep);
Cpp:
#include "PhysicsEngine.h"#include <BulletDynamics\Dynamics\btDynamicsWorld.h>void BulletTickCallback(const btDynamicsWorld *world, btScalar timeStep) { printf("The world just ticked by %f seconds\n", (float)timeStep);}PhysicsEngine::PhysicsEngine(){ world = new btDiscreteDynamicsWorld(...); world->setInternalTickCallback(BulletTickCallback, static_cast<void*>(this));}
The compiler is flagging my argument BulletTickCallback to setInternalTickCallback saying:
error C2664: 'btDynamicsWorld::setInternalTickCallback' : cannot convert parameter 1 from 'void (__cdecl *)(const btDynamicsWorld *,btScalar)' to 'btInternalTickCallback'1> None of the functions with this name in scope match the target type
This is the prototype function for btInternalTickCallback:
typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep);
Which looks the same as my function, but I'm not sure why it won't take it.
The simple example given on bullet site doesn't show much more than this, which I believe I've done:
void myTickCallback(const btDynamicsWorld *world, btScalar timeStep) { printf("The world just ticked by %f seconds\n", (float)timeStep);}// And then somewhere after you construct the world:mWorld->setInternalTickCallback(myTickCallback);
If I paste in that exact code it complains about the exact same thing for myTickCallback.
Am I missing something fundamental? I'm not experienced with function pointers.
Thanks!