Original Post
Hi, To be honest, I feel bad asking a question like this, but if anyone could help it would be much appreciated. Its late and I'm sure it's something stupid... I have a function to create an instance of my game engine, like so:
bool CreateEngine( Engine *pEngine )
{
// check if the global engine pointer is already set
if( g_pEngine )
return false;
// create the engine
try {
pEngine = new Engine();
}
catch( std::bad_alloc )
{
return false;
}
// return success
return true;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
Engine *pEngine = NULL;
if( !CreateEngine( pEngine ) )
{
// *snip*
}
delete pEngine;
}
The call to CreateEngine() returns true, and in the watch window I can see the Engine object is created OK. However, as soon as the function returns the pointer is set back to NULL. Can anyone figure out why? Many thanks.