I have a class called "Life" which loads each frame into a vector of images and plays it when needed. I need something that can load 960x540 frames so I surely abandoned trying to use spritesheets. This method i'm using now works but is extremely inefficient. Just using the load function causes the entire program to stop till the process of loading finishes. 10 or so frames causes a 1/2 second pause and any decent length animation of 200 frames causes a whopping 10 to 15 second lag. Of course I can't have this. Is this method impossible? I know there must be some way to load and play the frames of an animation that is 960x540. I just don't know how.
Here is my loading code.
DIR *dr;
struct dirent *en;
dr=opendir(folder.c_str());
for(int a=1;a<2000;a++)
{
if(en=readdir(dr))
{
if(en->d_name==NULL)
{
break;
}
if(a>2)
{
Image newimage;
newimage.loadFromFile(folder+en->d_name);
image.push_back(newimage);
}
}
else
break;
}
closedir(dr);
I'm sure its not dirent that is causing the process pause because I manually loaded each frame to test if it was dirent or not and it still halted the processing the same.
I also tried loading only portions at a time as needed by loading the next few frames as needed. This still caused a 1/2 second lag that happened every few frames.
I know that loading from files is not good on performance, since several have told me that before. So I'm looking for either a new method,or a fix to this current method. So any ideas?
I also would like to know if it would work to load into each image one loop at a time instead of all in one for() iterator.