I have this simple code I’m trying to run in order to learn how PhysX works, but it is crashing in the call to PxCreatePhysics.
#include <iostream>
#include <string>
#include <PxPhysicsAPI.h>
#include <extensions/PxDefaultErrorCallback.h>
#include <extensions/PxDefaultAllocator.h>
const int WINDOW_WIDTH=1024;
const int WINDOW_HEIGHT=768;
physx::PxFoundation* gFoundation = nullptr;
physx::PxPhysics* gPhysics = nullptr;
physx::PxProfileZoneManager* gProfileZoneManager = nullptr;
physx::PxDefaultErrorCallback gDefaultErrorCallback;
physx::PxDefaultAllocator gDefaultAllocatorCallback;
void check(void* p, const std::string& message)
{
if(p == nullptr)
{
std::cout << message << std::endl;
}
}
void initPhysX()
{
gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
check(gFoundation, "PxCreateFoundation Failed");
gProfileZoneManager = &physx::PxProfileZoneManager::createProfileZoneManager(gFoundation);
check(gProfileZoneManager, "PxProfileZoneManager::createProfileZoneManager failed");
bool recordMemoryAllocations = true;
gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, physx::PxTolerancesScale(), recordMemoryAllocations, gProfileZoneManager);
check(gPhysics, "PxCreatePhysics failed");
}
int main(int argc, char* argv[])
{
std::cout << "Hello PhysX" << std::endl;
initPhysX();
return EXIT_SUCCESS;
}
I’m using Visual Studio 2010. I don’t know what is wrong since the samples run just fine.