Hi. I have a simple(but maybe complex) question about IrrDevice.
As the topic subject, what is the difference between IrrDevice->closeDevice() and IrrDevice->drop() ?
In my project, I used closeDevice() when certain button(ex.QUIT or EXIT button) GUI Event occurs,
and used drop() after while(IrrDevice->run()) {} .
But some strange phenomenon happens when I changed closeDevice() to drop(), because I think it is more proper to use drop().
I only know that I should use drop() function when the device should be deleted (I.E., memory about device should be gone),
but things are not so easy as I think.
What is accurate difference between them?
What is difference between closeDevice() and drop() ?
What is difference between closeDevice() and drop() ?
From Seoul, South Korea
Re: What is difference between closeDevice() and drop() ?
When you use closeDevice(), you inform Irrlicht that you want him next time you call device->run() to return "false", so your rendering loop will finish and you can correctly drop the device (and other resources). If you will call drop() on the device, next call to device->run() will crash your app (well, any call to "device->..." will crash).
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: What is difference between closeDevice() and drop() ?
Yes, the idea is to always just call closeDevice in your app, and only do the drop at a single place after you left the render loop the last time. You should even call run() at least one more time, to handle the window close events properly.
Re: What is difference between closeDevice() and drop() ?
Oh I see.. I got it briefly.
Then what function do I have to use to wake up the closed device (the IrrDevice that called device->closeDevice()) ?
I mean, after I call closeDevice(), how can I make device->run() returns true to render the device?
Or should I just create a new device even I only closed device, not drop ?
Thank you for your answers, and thank you in advance!
Then what function do I have to use to wake up the closed device (the IrrDevice that called device->closeDevice()) ?
I mean, after I call closeDevice(), how can I make device->run() returns true to render the device?
Or should I just create a new device even I only closed device, not drop ?
Thank you for your answers, and thank you in advance!
From Seoul, South Korea
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: What is difference between closeDevice() and drop() ?
No, a closed device is dead, it just still occupies some memory. But usually even the window will disappear upon closeDevice already - only Windows has some problems here which is why you have to call run() once or twice after closeDevice. The drop will then mark the memory for disposal, usually removing everything immediately there. If you call drop earlier, this should also happen, but might fail due to internal references, or no proper clean up will leave some ressources, e.g. for d3d or the window handlers, left dangling in memory.
If you need the next device, create a new one after removing the old one. Better not two at once.
If you need the next device, create a new one after removing the old one. Better not two at once.