Code: Select all
class cEvent_c : public IEventReceiver
{
public:
int m_mouseX, m_mouseY;
virtual bool OnEvent(SEvent event);
};
Code: Select all
bool cEvent::OnEvent(irr::SEvent event)
{
if(event.EventType)
{
//Keyboard input
if(event.EventType == EET_KEY_INPUT_EVENT)
{
switch(event.KeyInput.Key)
{
default:
return true;
}
}
//Mouse input
else if(event.EventType == EET_MOUSE_INPUT_EVENT)
{
m_mouseX = event.MouseInput.X;
m_mouseY = event.MouseInput.Y;
return true;
}
}
return false;
}
Code: Select all
class cApp_c
{
private:
//Irrlicht
IrrlichtDevice *m_irrDevice;
IVideoDriver *m_videoDriver;
ISceneManager *m_sceneMan;
IGUIEnvironment *m_GUIEnv;
cEvent m_event;
//FMOD
FMOD::System *m_soundSystem;
public:
//Constructor/Deconstructor
cApp_c();
~cApp_c();
//Get Methods
IrrlichtDevice *getIrrlichtDevice();
IVideoDriver *getVideoDriver();
ISceneManager *getSceneManager();
IGUIEnvironment *getGUIEnvironment();
cEvent getEventReceiver();
FMOD::System *getSoundSystem();
bool isRunning();
int getMouseX();
int getMouseY();
//Set Methods
void setIrrlichtDevice(IrrlichtDevice *newDevice);
void setVideoDriver(IVideoDriver *newDriver);
void setSceneManager(ISceneManager *newSceneMan);
void setGUIEnvironment(IGUIEnvironment *newGUIEnv);
void setSoundSystem(FMOD::System *newSoundSystem);
};
Code: Select all
//Create Irrlicht device
cEvent eventReceiver = app->getEventReceiver();
app->setIrrlichtDevice(createDevice(EDT_DIRECT3D9, dimension2d<s32>(1024, 768), 32, false, true, true, &eventReceiver));
Irrlicht Engine version blah
Microsoft Windows XP
Using renderer Direct3D 9.0
RADEON 9800 SERIES
and it will then crash. After doing some debugging I have found that this piece of code in the engine crashes:
Code: Select all
//! send the event to the right receiver
void CIrrDeviceStub::postEventFromUser(SEvent event)
{
bool absorbed = false;
if (UserReceiver)
absorbed = UserReceiver->OnEvent(event);
if (!absorbed && GUIEnvironment)
absorbed = GUIEnvironment->postEventFromUser(event);
if (!absorbed && SceneManager)
absorbed = SceneManager->postEventFromUser(event);
}
Theres something wrong with UserReceiver:
But I'm not sure what. Anyone got any ideas?