Hi,
I have a .irr file scene, that takes more than 2 minutes to load, and my game is blocked in the time of loading, So I was wondring is there a way to lanch the loading of my scene and playing an animation(loading bar) or a video in the same time ?
Threads in Irrlicht
Re: Threads in Irrlicht
Yes, of course. You can load a data (textures, meshes etc.) from other threads (in OpenGL for textures You have to use main thread, so load just RAW texture data loadImageFromFile in other thread, but next call IVideoDriver::addTexture). At the same time You can show loading progress bar. I did in this way loading splash screen for Sky Devil: Stairway to Heaven (I use Boost threads).
PS. For *.irr files you have to little modify a loader sources.
PS. For *.irr files you have to little modify a loader sources.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: Threads in Irrlicht
@Nadro thanks for the quick responce,
Is there any samples or code snipets that I can use or follow ?
Is there any samples or code snipets that I can use or follow ?
Re: Threads in Irrlicht
I don't think so, but maybe other members will have some links. Anyway I think that Boost thread examples would be enough in this case.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: Threads in Irrlicht
Hi st0ph,
since your model loading function blocks the app, you could start the progress bar as a thread before you begin to load the model.
To do this with std::threads you should do something like this:
If this doesn't help you, you could try to load the model within a thread, start the progressbar and apply the texture as soon as the progressbar finishes:
I hope this works and I could help you
Best regards and have a nice day
Ritti
since your model loading function blocks the app, you could start the progress bar as a thread before you begin to load the model.
To do this with std::threads you should do something like this:
Code: Select all
std::thread progressbar = std::thread(loadBar); //function to show the progress bar
progressbar.detach();
loadModel(); //function to load the model
Code: Select all
loadModel(){
irr_node = device->getSceneManager()->addAnimatedMeshSceneNode(
device->getSceneManager()->getMesh("../../media/yourmodel"),0, 0);
build.cube.irr_node->setPosition(core::vector3df(0,0,0));
}
int main(int argc, char* argv[]){
std::thread loadM = std::thread(loadModel);
loadM.detach();
loadBar();
irr_node->setMaterialTexture( 0, device->getVideoDriver()->getTexture("../../media/some_texture.png") );
}
Best regards and have a nice day
Ritti