You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
As the title says my EventReceiver crashes my game. The game runs perfectly when I comment out:
" device->setEventReceiver(&receiver); "
My EventReceiver is placed in some cpp and h files besides the core.
The weird part is my game does not crash here but first when I use this line:
" ISceneNode* map = smgr->addOctTreeSceneNode(smgr->getMesh(file)); "
I even declare a couple of pointers in some lines between.
Anyone else have had the same problem or maybe just have a solution??
/Saku
Last edited by Saku on Fri May 27, 2005 4:59 pm, edited 1 time in total.
Your EventReceiver may implement an OnEvent() function but does not inherit from IEventReceiver(). After a mesh is successfully loaded, a message is passed to the EventReceiver and the exeption occurs.
I don't think this really matters but now you're constantly sending events, so ry changing "return true;" into "return false;". How do you declare the variable "receiver" ? Make sure it's declared as "MyEventReceiver receiver;" and not as a pointer, although, that should throw a compile-time error...
Neither of those two should make a difference - you don't need a constructor if you're not defining any extra fields, and virtual just means that the function can be overridden in derived classes.
But I'm surprised at how little information Saku is giving. Frankly I'm surprised bal and TD have been able to give as much advice as they did. Am I not seeing a link or something?
Anyway, post the relevant section of your main function. We should at least be able to look at any event receiver related stuff there - since the most likely cause of a crash is an invalid pointer.
You are so very right! None of them worked.
And if you want more of the code, just ask. I have no problem posting all my code here, but I thought ppl would just be annoyed by page on page of unrelevant code. I've packed all my code and uploaded here: http://www.zOneOne.dk/files/pack.zip
Also I'm very thankfull for ppl being willing to help me.
If you got any questions or anything just ask!
you are declaring your variable "receiver" in CCore.cpp in InitDevice(), but it's only a local variable. So as soon as InitDevice() ends, your variable "receiver" is destroyed, memory freed ...
I would define your receiver as part of the CCore class.