Is Irrlicht thread-safe?
-
Andi.Dascalu
- Posts: 14
- Joined: Wed Sep 21, 2011 6:44 am
Is Irrlicht thread-safe?
More precisely, can I make a loading screen with the actual loading happening in another thread(loading textures and meshes), while the main thread is responsible with the drawing?
Re: Is Irrlicht thread-safe?
Yes you can hack something like that. However unfortunately though, Irrlicht is NOT thread safe.
Re: Is Irrlicht thread-safe?
Only loading 1 texture or mesh per application loop has always left all my applications responsive.Andi.Dascalu wrote:More precisely, can I make a loading screen with the actual loading happening in another thread(loading textures and meshes), while the main thread is responsible with the drawing?
Something along this idea will work for you:
Code: Select all
list<string> texturesToLoad;
texturesToLoad.push_back ("texture1.png");
...
list<string>::Iterator iter = texturesToLoad.begin ();
while (device->run ()) {
driver->beginScene (true, true, SColor (255, 100, 101, 140));
smgr->drawAll ();
driver->endScene ();
if (iter != texturesToLoad.end ()) {
ITexture *texture = driver->getTexture (*iter);
iter++;
}
}
-
Andi.Dascalu
- Posts: 14
- Joined: Wed Sep 21, 2011 6:44 am
Re: Is Irrlicht thread-safe?
Thanks for the answers. I implemented something like that aanderse but even by loading one texture at a time there was some lag, but it looks like I will have to cope with it.
Re: Is Irrlicht thread-safe?
i'm somewhat shocked to hear that because i've loaded many different meshes and textures and never had any problem with itAndi.Dascalu wrote:Thanks for the answers. I implemented something like that aanderse but even by loading one texture at a time there was some lag, but it looks like I will have to cope with it.
texture or mesh?
what format and size?
-
Andi.Dascalu
- Posts: 14
- Joined: Wed Sep 21, 2011 6:44 am
Re: Is Irrlicht thread-safe?
I am programming for mobile devices, Android specifically; the textures are in .png format and the largest is 1024*1024. To load 10 of these it takes about 2 sec in which time I would have liked to have sharp response to input.
An idea springed to my mind though, to use another instance of the VideoDriver to do the loading in another thread. Will try to implement it today.
An idea springed to my mind though, to use another instance of the VideoDriver to do the loading in another thread. Will try to implement it today.
-
Radikalizm
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
Re: Is Irrlicht thread-safe?
Why use such a texture size for a device which probably is never going to be able to display it in that resolution? That's just throwing away memory and performanceAndi.Dascalu wrote:I am programming for mobile devices, Android specifically; the textures are in .png format and the largest is 1024*1024. To load 10 of these it takes about 2 sec in which time I would have liked to have sharp response to input.
An idea springed to my mind though, to use another instance of the VideoDriver to do the loading in another thread. Will try to implement it today.
-
Andi.Dascalu
- Posts: 14
- Joined: Wed Sep 21, 2011 6:44 am
Re: Is Irrlicht thread-safe?
One of them is a texture atlas, it keeps all of my buttons in one place, that is why it is so big, and the others have their purpose, but this is not the point of the discussion.
Re: Is Irrlicht thread-safe?
So the answer was in your hands all the time. Split your texture into smaller sub-atlases.
