Is Irrlicht thread-safe?

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
Andi.Dascalu
Posts: 14
Joined: Wed Sep 21, 2011 6:44 am

Is Irrlicht thread-safe?

Post by Andi.Dascalu »

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?
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Is Irrlicht thread-safe?

Post by ACE247 »

Yes you can hack something like that. However unfortunately though, Irrlicht is NOT thread safe.
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

Re: Is Irrlicht thread-safe?

Post by aanderse »

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?
Only loading 1 texture or mesh per application loop has always left all my applications responsive.

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?

Post by Andi.Dascalu »

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.
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

Re: Is Irrlicht thread-safe?

Post by aanderse »

Andi.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.
i'm somewhat shocked to hear that because i've loaded many different meshes and textures and never had any problem 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?

Post by Andi.Dascalu »

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.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Is Irrlicht thread-safe?

Post by Radikalizm »

Andi.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.
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 performance
Andi.Dascalu
Posts: 14
Joined: Wed Sep 21, 2011 6:44 am

Re: Is Irrlicht thread-safe?

Post by Andi.Dascalu »

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.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Is Irrlicht thread-safe?

Post by mongoose7 »

So the answer was in your hands all the time. Split your texture into smaller sub-atlases.
Post Reply