noobish question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Guest

Post by Guest »

lol, i thought you could fix that "irrDevice->close();" error yourself :)

i suggest to read the irrlicht tutorials.
thomas55

Post by thomas55 »

the

23 C:\Irrlicht\Game\Keyinput.h `irrDevice' undeclared (first use this function)
thomas55

Post by thomas55 »

ive tryed device->drop(); as well
Guest

Post by Guest »

IrrlichtDevice* irrDevice;

should do it - i wonder how you can even run your app without it o.O" (again, i highly recommend to read the irrlicht tutorials :) )
thomas55

Post by thomas55 »

this doesent work either ive read the tutorials and they say to use
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; 
 } 

};

thomas55

Post by thomas55 »

void value not ignored as it ought to be this is the only error i get now
MindGames
Posts: 32
Joined: Sat Jul 16, 2005 2:02 am

Post by MindGames »

#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

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
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

My god do you even have a main loop?

is the event reciever the only code in your program?!

#pragma comment(lib, "irrlicht.lib") isn't?

you have #pragma comment(lib, "Engine.lib")
thomas55

Post by thomas55 »

there is a game in main.cpp i just want to make the "esc" key ecape the game so i can make it fullscreen
thomas55

Post by thomas55 »

problem solved thanks ive put the book on order as i can use it for reference somtimes i foget some simple stuff thanks
thomas55

Post by thomas55 »

also how can i add this to my main loop i need the escape key to end the game
Post Reply