Event Receiver Problems

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.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Event Receiver Problems

Post by monkeycracks »

I've tried several things to fix this, and I couldn't so I figured I'd post here.

Code: Select all

void CGame::run()
{
CGame receiver;
device = createDevice(EDT_OPENGL,dimension2d<s32>(1024, 768), 32, true, true, true, &receiver);;

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();

loadscene();
loadplayer(); 
while(device->run())
{
  driver->beginScene(true, true, SColor(0,200,200,200));
  smgr->drawAll();
  guienv->drawAll();
  driver->endScene();
}
device->drop();
}
That code's pretty self-explanatory.

Code: Select all

class CGame : public IEventReceiver
{
public:

	CGame();
	void run();
	bool OnEvent(SEvent event)
	{
	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_ESCAPE)
	{
			device->closeDevice();
	}
}

private:
	IrrlichtDevice *device;
	void loadscene();
	void loadplayer();
	ITerrainSceneNode* TestGroundTerrain;
	ITriangleSelector* TestGroundSelector;
	IMetaTriangleSelector* metaSelector;
	IAnimatedMeshSceneNode* playermesh;
	int scenenumber;
};
Theres my class located in the header file.
Anyone see any problems?
Last edited by monkeycracks on Sun Aug 27, 2006 9:58 am, edited 2 times in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes.
wooohoh
Posts: 5
Joined: Fri Aug 25, 2006 9:02 am

return

Post by wooohoh »

return true / false statement is missing :shock:
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Ah your right, however I added it in and it didn't help.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

what i said was wrong

what IPv6 says below is right! :)
Last edited by Spintz on Fri Aug 25, 2006 2:57 pm, edited 1 time in total.
Image
IPv6
Posts: 188
Joined: Tue Aug 08, 2006 11:58 am

Post by IPv6 »

replace receiver in this

Code: Select all

CGame receiver;
device = createDevice(EDT_OPENGL,dimension2d<s32>(1024, 768), 32, true, true, true, &receiver);;
with 'this'

Code: Select all

device = createDevice(EDT_OPENGL,dimension2d<s32>(1024, 768), 32, true, true, true, this);;
:)
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Theres got to be something I'm missing, I'm a bit tired so sorry if Its really obvious.

Code: Select all

#include "Game.h"
#include "IamarCamera.h"
#include <stdio.h>

CGame::CGame()
{
}

void CGame::run()
{
device = createDevice(EDT_OPENGL,dimension2d<s32>(1024, 768), 32, true, true, true, this);; 

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();

loadscene();
loadplayer(); 
while(device->run())
{
  driver->beginScene(true, true, SColor(0,200,200,200));
  smgr->drawAll();
  guienv->drawAll();
  driver->endScene();
}
device->drop();
}
This is my code.



This is in a header file.

Code: Select all

class CGame : public IEventReceiver
{
public:

	CGame();
	void run();
	bool OnEvent(SEvent event)
	{
	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_ESCAPE)
	{
			device->closeDevice();
			return true;
	
	}
	return false;
}

private:
	IrrlichtDevice *device;
	void loadscene();
	void loadplayer();
	ITerrainSceneNode* TestGroundTerrain;
	ITriangleSelector* TestGroundSelector;
	IMetaTriangleSelector* metaSelector;
	IAnimatedMeshSceneNode* playermesh;
	int scenenumber;
};
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

What exactly is the problem that you are having? Does the code not compile for you, does it crash, ...
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Nothing happens when the Escape key is pressed, as it should close the application.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Works just fine for me. I pasted your code into a main.cpp for one of the examples. It compiled and ran with no problems. Pressing escape closed the window and the program exited.

The only change I had to make was to comment out the calls to loadscene() and loadplayer() because you provided no definitions.

What platform are you using? Maybe KEY_ESCAPE is mapped wrong for your platform?
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Sorry for not defining them

http://ultimate-ownage.com/gh.zip

theres a link to my project zip file

I hope you can figure it out because I'm totally clueless.
jam
Posts: 409
Joined: Fri Nov 04, 2005 3:52 am

Post by jam »

Had to comment out

Code: Select all

//IamarCamera* Icamera;
//Icamera = new IamarCamera((ISceneNode*)playermesh, smgr, -1); 
//smgr->setActiveCamera(Icamera);
Otherwise the code works fine here on my windows box compiled with Dev C++ 4.9.9.2 using Irrlicht 1.1.
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I don't get any errors or warnings when compiling with it.
Thats not my problem

My problem is the event receiver doesn't work.

And I use 1.0 because IamarCam doesn't work with 1.1
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Expect some side effects from badly written cameras. They have their own event receiver and might interfere with yours.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I tried commenting out everything that had to do with IamarCam and added in an FPS cam and it still didn't work.
Post Reply