If i dont have an EventReciver my game works fin, the moment i pass one to the IrrlichtDevice the game doesnt run.
It crashes at the start of the main game loop.
heres some code:
Code: Select all
int _tmain(int argc, _TCHAR* argv[])
{
//Create a pointer to the BaseLogic class for easy access.
BaseLogic* pBaseLogic = BaseLogic::GetInstance();
//Initialize the BaseLogic class which runs everything else.
pBaseLogic->Init();
//Create a pointer to the Irrlicht Engine for easy access.
IrrlichtDevice* pEngine = pBaseLogic->GetEngine();
while(pEngine->run())
{
if(pEngine->isWindowActive())
{
BaseLogic::GetInstance()->Update(0);
}
else
Sleep(100);
}
return 0;
}Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
MyEventReceiver()
{
}
bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
switch (event.KeyInput.Key)
{
case irr::KEY_KEY_W:
return true;
case irr::KEY_KEY_D:
return true;
}
}
return false;
}
};Code: Select all
void BaseLogic::Init()
{
pEngine = createDevice(EDT_DIRECT3D9,dimension2d<s32>(1024, 768),16,false,false,false,0);
pEngine->setWindowCaption(L"Bleh");
MyEventReceiver receiver;
pEngine->setEventReceiver(&receiver);
pVideoDriver = pEngine->getVideoDriver();
pScene = pEngine->getSceneManager();
Camera::GetInstance()->Init(); //Initialise the Camera
Gui::GetInstance()->Init(); //Initialize the Gui
//TEMP//
IAnimatedMesh* mesh = pScene->getMesh("./sydney.md2");
IAnimatedMeshSceneNode* node = pScene->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 310);
node->setMaterialTexture( 0, pVideoDriver->getTexture("./sydney.bmp") );
}
//pScene->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
//END TEMP//
}the error is
Unhandled exception at 0x06a4f99c in Cislunar.exe: 0xC0000005: Access violation reading location 0x06a4f99c.
I have tried lots of different bits of EventReceiver code, from different tutorials, none work for me.
oh btw im using Visual C++ 2005 Express Edition if that makes any difference.