noobish question
this doesent work either ive read the tutorials and they say to use
device->drop(); but thatt dont work
device->drop(); but thatt dont work
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;
using namespace io;
#pragma comment(lib, "Engine.lib")
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
IrrlichtDevice* irrDevice = device->drop();
break;
}
}
return false;
}
};
The following is wrong#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;
using namespace io;
#pragma comment(lib, "Engine.lib")
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
IrrlichtDevice* irrDevice = device->drop();
break;
}
}
return false;
}
};
IrrlichtDevice* irrDevice = device->drop();
If you have access to 'device' then device->drop() would work. The problem is that you do not have access to 'device.
Is device a global variable? You cannot call a function on a variable that you have no access to. Unless a variable is a global, your MyEventReceiver class will have no access to it. You can solve the problem by making device a global variable or you could pass in the value when you create the class. e.g.
class MyEventReceiver : public IEventReceiver
{
private:
IrrlichtDevice* m_pDevice;
public:
MyEventReceiver(IrrlichtDevice* irrDevice)
{
m_pDevice = irrDevice;
}
virtual bool OnEvent(SEvent event)
{
...
// want to shut down
m_pDevice->drop();
}
You should try to get hold of a good learning C++ book because this is really just basic C++. I found 'C++ for dummies' (take no notice of the name - it is quite a good book) to be a really good get you started book which gave good examples and answered most of the questions I had when I started with C++.
Hope this helps