problem with event receiver in irr0.7.1

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!
Post Reply
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

problem with event receiver in irr0.7.1

Post by arras »

I am rewriting my demo for Irrlicht v.0.7.1. When I pass my event receiver to createDevice function everything compile just fine but when I run exe I get error mesage:

...exe generated errors and will be terminated by Windows system. Restart program.

I tried to recompile 04.Movement example (to be sure that it is not my event receiver which is wrong) and got the same problem. Compilation is OK but when I try to run exe I get the same message.

Does somebody have similar problem?

...I tried it on both DirectX and OpenGL and two mashines, one with WinXP and second with Win2000.

code:

Code: Select all

bool key[KEY_KEY_CODES_COUNT];
        
class SEventReceiver : public IEventReceiver
{
public: 
	virtual bool OnEvent(SEvent event)
	{
		if(event.EventType == irr::EET_KEY_INPUT_EVENT)
        {
           key[event.KeyInput.Key] = event.KeyInput.PressedDown;
           return true;
		}
		return false;
	}	
};


int main()
{
SEventReceiver receiver;
    IrrlichtDevice *device = createDevice
        (video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 32, false, false, false, &receiver);
...
[/url]
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Be sure you're linking properly to the new Irrlicht 0.7.1 lib and that the DLL you're linking to matches the lib.

I had this same problem, with other things as well, it was because the DLL I was using was compiled with 0.7.1, but I was still linking to the old 0.7 LIB file.
Romanito
Posts: 1
Joined: Mon Nov 29, 2004 5:28 pm
Location: France

Post by Romanito »

Hi, I'm having the same problem with Irrlicht 0.7.1, just like arras's description. As a new user I've downloaded the 0.7 full package and extracted the 0.7.1 update over it to replace old files.
... so I'm pretty sure I'm not linking to the 0.7 lib, I checked all the files dates (2004-09-25).

It must be something else, but I could't figure it out so far...

I'm using Dev-C++ 4.9.9.0 with g++ 3.4.2 on a Windows 2000 system.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Romanito >> I did exactly the same and I also use DevC++

Spintz >> can you compile Movement example and run it (on Irr0.7.1)? Which compiler do you use?
Bel'ni
Posts: 7
Joined: Tue May 11, 2004 7:06 am
Location: The Netherlands

Post by Bel'ni »

Hmm, me too. :?

I have had this same error/problem. When i ran tutorial 6, its says something about using 0.7 lib and found the 0.7.1. dll.

Using MSVC6, DirectX9....

I switched back to 0.7 and all was perfect again.
Watch, Think and Tinker.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I'll try some things like svitching to 0.7.0 and see what it does....
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Try Debugging, it sounds like a standard windows access violation. Are you using any pointers your forgot to set?
The Robomaniac
Project Head / Lead Programmer
Centaur Force
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Robomaniac >> exe crashes only if there is event receiver passed in to create device, means it should be problem with event receiver. Only thing which may cause some problems is that as you can see array bool key[KEY_KEY_CODES_COUNT] is not inicialized. Thats becouse if I try to do it outside of main() I get compile error. With Irrlicht 0.6 it was functioning without initialization.

Aslo if I try to pass any other receiver, like one from Movement example where there are no arrays, it crashes exactly in the same way, so its probably not array initialization issue.

I will try to test it more. I can try to strip code to most basic stuff to make sure it is not something in rest of the code.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

OK it is problem of event receiver and v.0.7.1. Code below run on v.0.7.0 but crashes when compiled with 7.1 (compile fine, exe crashes)

Code: Select all

#include "irrlicht.h"
using namespace irr;

class MyEventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(SEvent event)
	{
		if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
		{
			if(event.KeyInput.Key)
			{
				return true;
			}
		}
		return false;
	}
};

int main()
{   
    MyEventReceiver receiver;
    IrrlichtDevice *device = createDevice
        (video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 32, false, false, false, &receiver);
	
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment* guienv = device->getGUIEnvironment();

	while(device->run())
	{		
        driver->beginScene(true, true, video::SColor(0,0,0,0));
		smgr->drawAll();
		guienv->drawAll();
        driver->endScene();
    }
		
	device->drop();
	return 0;
}
I think I can post it in Bugs forum now.
Post Reply