[SOLVED]Two irrlicht devies - 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.
Post Reply
vins
Posts: 51
Joined: Mon Aug 16, 2004 6:14 pm
Location: Sofia, Bulgaria
Contact:

[SOLVED]Two irrlicht devies - problems

Post by vins »

I'm creating two irrlicht devices. But when I delete the second device the first one's run() returns false as if it wants to be deleted.
I can't understand why this happens. Aren't they two different instances?
Also when used in GUI framework the messages that closeDevice sends, tells the framework to close the application:

Code: Select all

void CIrrDeviceWin32::closeDevice()
{
	MSG msg;
	PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
	PostQuitMessage(0);
	PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
	DestroyWindow(HWnd);
	Close=true;
}
Currently I delete the device like : delete device;
Is that bad? The window handle is being deleted by the GUI framework and I don't use the device after that so it should not be a problem, right?

Thanks.
Last edited by vins on Tue Feb 16, 2010 12:47 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Usually you should run closeDevice() first before deleting the device. And it shouldn't really quit gui-framworks as the quit message is consumed immediately afterward. I 'm not sure why it is done the way it is done. Looks like something grown from experiences, I think formerly people needed another run() after the closeDevice() sometimes. You might want to call also clearSystemMessages () before or after the closeDevice() to make sure no events for a closed device get passed on to a new device which you create afterwards.

But I suspect you already tried that stuff... can you paste a quick example we can use for testing?

Another thing - don't use delete in Irrlicht for objects created with a create function. Use device->drop() instead and set the pointer afterward to 0. It's just safer, although in this case it probably makes no difference here.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
vins
Posts: 51
Joined: Mon Aug 16, 2004 6:14 pm
Location: Sofia, Bulgaria
Contact:

Post by vins »

CuteAlien wrote:...people needed another run() after the closeDevice() sometimes...
Thanks alot man! I haven't tried that. I just added a call to run() after closeDevice() and it now works fine :D
Post Reply