Event Receiver stopped working

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.
Post Reply
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Event Receiver stopped working

Post by [dx/x]=HUNT3R »

I just converted my old code from a more straight C type structure which required a lot of global variables to a more object oriented C++ structure. And now the event receiver decides to just stop working altogether. I have a opening menu screen to select DirectX or OpenGL just like the techdemo does and the event receiver works fine there. But after you click on start and the demo loading screen shows up, the event receiver stops working and I have to end the program with the task manager or something to get out b/c the menu buttons don't work. Even pressing alt-f4 doesn't do anything. The mouse shows up and works, but it's supposed to be hidden in the loading screens. I've gone over the code a thousand times and everything is correct as far as I can tell. Both event receivers are coded the same way and one works but the other doesn't. BTW, I'm doing them the same way the techdemo does, my menu and my demo are both separate classes that inherit from IEventReceiver. Has anyone else had this problem or have any ideas.

If you want to see all the code it's on the Supa G website in the downloads section. It's the newer v0.3.8 source code.
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

does your application crash here ->

Code: Select all

	 if ( device->getSceneManager() && device->getSceneManager()->getActiveCamera())
	{
		device->getSceneManager()->getActiveCamera()->OnEvent(event);
		return true;
	}
because thats were the techdemo makes the error with 0.4.2
and also in my modified Techdemo App.
I've been absent for really long, but i'm ready to reign my terror on you once again, mwuahahahahaha
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

No, it does not crash. The event receiver simply just does not work. The loading screens play and the mouse shows up even though it's supposed to be hidden, and then it goes into the main menu but I cannot do anything because the buttons do not work. I have to hit the Windows button on the keyboard and close the program from the taskbar...
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

do you have something similar to the following:

Code: Select all

customEventReceiver receiver;
IrrlichtDevice *device =
		createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 16, false, false, &receiver);
the "&receiver" at the end is key. I left it off once and wondered why it didn't work :P
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

similar yes... My menu and demo classes both inherit from the IEventReceiver class. So they each have a public member function

Code: Select all

virtual bool OnEvent(SEvent event);
that overrides the Irrlicht OnEvent function and gets any user input. So my createDevice looks like

Code: Select all

device = createDevice(driverType, core::dimension2d<s32>(1024, 768), bitDepth, true, true, this);
This is the same way the techdemo demo works and as I said before the menu works fine and responds to input but the demo does not respond to input. I have checked the code a hundred times and I'm sure I didn't type in anything wrong, I just may need to do something different since I made the source more object oriented.
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

I've been having alittle trouble with mine... but .. it solved its self some how. I don't know how, but my even reciever works now. (it didn't last night :? )
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

DarkWhoppy wrote:I've been having alittle trouble with mine... but .. it solved its self some how. I don't know how, but my even reciever works now. (it didn't last night :? )
ahhhh, the joys of convoluted programming :D
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

At the top of your receiver do you check for log events? These events begin coming in before everything is fully created, so some of your pointers may not be initialized yet, etc. At the top of your receiver you should check for log events and return immediately (and possibly print out the log message if you want).
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

I commented out everything in the OnEvent function and just put in a check for the ESC key to quit the program. It doesn't work... it's like it's just not checking the event receiver for some reason.
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

Still haven't solved this problem, anyone have any new ideas?
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

I seemed to have fixed it but it kinda doesn't make sense... at least it works now though.

If you have the same problem let me know and I'll try to explain what I did to fix it; otherwise, I'm hungry and I don't feel like typing right now.
CM
Posts: 4
Joined: Wed Jan 07, 2004 1:04 am

Post by CM »

Like Boogle said I put a check for log events at begining fixed it for me.

Code: Select all

bool CGame::OnEvent(SEvent event)
{
	if(event.EventType == EET_LOG_TEXT_EVENT)
	{
		return true;
	} 

	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_ESCAPE &&
		event.KeyInput.PressedDown == false)
	{
		// user wants to quit.
		device->closeDevice();
	}
	else
	if ((event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_SPACE &&
		event.KeyInput.PressedDown == false) ||
		(event.EventType == EET_MOUSE_INPUT_EVENT &&
		event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP))
	{
		// shoot 
	}
	else
	if (device->getSceneManager()->getActiveCamera())
	{
		  device->getSceneManager()->getActiveCamera()->OnEvent(event); 
		return true;
	}

	return false;
}
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

I don't check for log events, my problem was something else. I put a check, isWindowActive(), in my logic before the loading screens start like so

Code: Select all

if (device->isWindowActive()){
     Load_Intros();
} // end if
And strangely enough that seems to have fixed the problem. Before I just simply called Load_Intros(); and they would start running but the mouse would still be visible and the event receiver would not work. Strange.
Post Reply